Commit fb8d2656 authored by YIyiyi's avatar YIyiyi
parents 50a0bf8d 7b06f27e
...@@ -185,7 +185,7 @@ export default { ...@@ -185,7 +185,7 @@ export default {
this.form.id && this.$delete(this.form, "id"); this.form.id && this.$delete(this.form, "id");
}, },
// 分页 // 分页
handleChange(num) { handlechange(num) {
this.current = num; this.current = num;
this.getMatterquestionData(); this.getMatterquestionData();
}, },
......
...@@ -23,6 +23,7 @@ import com.mortals.xhx.module.app.model.*; ...@@ -23,6 +23,7 @@ import com.mortals.xhx.module.app.model.*;
import com.mortals.xhx.module.app.service.*; import com.mortals.xhx.module.app.service.*;
import com.mortals.xhx.module.site.model.SiteEntity; import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.service.SiteService; import com.mortals.xhx.module.site.service.SiteService;
import com.mortals.xhx.utils.EncodeUtil;
import com.mortals.xhx.version.model.VersionEntity; import com.mortals.xhx.version.model.VersionEntity;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -34,6 +35,7 @@ import com.mortals.xhx.module.app.dao.AppDao; ...@@ -34,6 +35,7 @@ import com.mortals.xhx.module.app.dao.AppDao;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.io.File; import java.io.File;
import java.nio.charset.Charset;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -130,7 +132,13 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L ...@@ -130,7 +132,13 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L
FileUtil.del(disPath); FileUtil.del(disPath);
} }
//ZipUtils.unzip(new File(targetFilePath), disPath); //ZipUtils.unzip(new File(targetFilePath), disPath);
ZipUtil.unzip(targetFilePath, disPath); String fileEncode ="UTF-8";
try {
fileEncode = EncodeUtil.getEncode(targetFilePath,true);
} catch (Exception e) {
log.error("异常",e);
}
ZipUtil.unzip(targetFilePath, disPath, Charset.forName(fileEncode));
//更新 //更新
appEntity.setDistributeFilePath(disPath); appEntity.setDistributeFilePath(disPath);
appEntity.setDistribute(YesNoEnum.YES.getValue()); appEntity.setDistribute(YesNoEnum.YES.getValue());
...@@ -158,7 +166,13 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L ...@@ -158,7 +166,13 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L
FileUtil.del(disPath); FileUtil.del(disPath);
} }
// ZipUtils.unzip(new File(targetFilePath), disPath); // ZipUtils.unzip(new File(targetFilePath), disPath);
ZipUtil.unzip(targetFilePath, disPath); String fileEncode ="UTF-8";
try {
fileEncode = EncodeUtil.getEncode(targetFilePath,true);
} catch (Exception e) {
log.error("异常",e);
}
ZipUtil.unzip(targetFilePath, disPath, Charset.forName(fileEncode));
return Rest.ok("基础应用部署成功!"); return Rest.ok("基础应用部署成功!");
} }
......
...@@ -14,6 +14,7 @@ import com.mortals.xhx.module.app.model.AppVersionQuery; ...@@ -14,6 +14,7 @@ import com.mortals.xhx.module.app.model.AppVersionQuery;
import com.mortals.xhx.module.app.service.AppService; import com.mortals.xhx.module.app.service.AppService;
import com.mortals.xhx.module.site.model.SiteEntity; import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.service.SiteService; import com.mortals.xhx.module.site.service.SiteService;
import com.mortals.xhx.utils.EncodeUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
...@@ -23,6 +24,7 @@ import com.mortals.xhx.module.app.model.AppVersionEntity; ...@@ -23,6 +24,7 @@ import com.mortals.xhx.module.app.model.AppVersionEntity;
import com.mortals.xhx.module.app.service.AppVersionService; import com.mortals.xhx.module.app.service.AppVersionService;
import java.io.File; import java.io.File;
import java.nio.charset.Charset;
import java.util.Date; import java.util.Date;
...@@ -71,8 +73,14 @@ public class AppVersionServiceImpl extends AbstractCRUDServiceImpl<AppVersionDao ...@@ -71,8 +73,14 @@ public class AppVersionServiceImpl extends AbstractCRUDServiceImpl<AppVersionDao
if (FileUtil.isDirectory(disPath)) { if (FileUtil.isDirectory(disPath)) {
FileUtil.del(disPath); FileUtil.del(disPath);
} }
String fileEncode ="UTF-8";
try {
fileEncode = EncodeUtil.getEncode(targetFilePath,true);
} catch (Exception e) {
log.error("异常",e);
}
// ZipUtils.unzip(new File(targetFilePath), disPath); // ZipUtils.unzip(new File(targetFilePath), disPath);
ZipUtil.unzip(targetFilePath, disPath); ZipUtil.unzip(targetFilePath, disPath, Charset.forName(fileEncode));
return disPath; return disPath;
} }
......
...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.site.service.impl; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.site.service.impl;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.URLUtil; import cn.hutool.core.util.URLUtil;
import cn.hutool.core.util.ZipUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo; import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
...@@ -56,6 +57,7 @@ import java.util.*; ...@@ -56,6 +57,7 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_IMAGE_URL; import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_IMAGE_URL;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_URL;
/** /**
* SiteService * SiteService
...@@ -99,54 +101,61 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -99,54 +101,61 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Autowired @Autowired
private IDeviceFeign deviceFeign; private IDeviceFeign deviceFeign;
private volatile Boolean refresh = false;
@Override @Override
protected void updateBefore(SiteEntity entity, Context context) throws AppException { protected void updateBefore(SiteEntity entity, Context context) throws AppException {
//校验下前后名称是否一直 如果不一致 同步修改所以关联 //校验下前后名称是否一直 如果不一致 同步修改所以关联
SiteEntity oldSite = this.get(entity.getId(), context); SiteEntity oldSite = this.get(entity.getId(), context);
if(!oldSite.getSiteName().equals(entity.getSiteName())){ if (!oldSite.getSiteName().equals(entity.getSiteName())) {
//todo //todo
//更新关联站点名称 //更新关联站点名称
updateAssociateSiteName(oldSite,entity, context); updateAssociateSiteName(oldSite, entity, context);
//通知设备更新站点信息
DevicePdu devicePdu = new DevicePdu(); refresh = true;
devicePdu.setSiteId(entity.getId());
deviceFeign.refreshMessage(devicePdu);
} }
super.updateBefore(entity, context); super.updateBefore(entity, context);
} }
private void updateAssociateSiteName(SiteEntity oldSite,SiteEntity newSite, Context context) {
private void updateAssociateSiteName(SiteEntity oldSite, SiteEntity newSite, Context context) {
//更新窗口站点名称 //更新窗口站点名称
WindowEntity windowEntity = new WindowEntity(); WindowEntity windowEntity = new WindowEntity();
windowEntity.setSiteName(newSite.getSiteName()); windowEntity.setSiteName(newSite.getSiteName());
WindowEntity condition = new WindowEntity(); WindowEntity condition = new WindowEntity();
condition.setSiteName(oldSite.getSiteName()); condition.setSiteName(oldSite.getSiteName());
windowService.updateBatch(windowEntity,condition,context); windowService.updateBatch(windowEntity, condition, context);
/* List<WindowEntity> windowEntityList = windowService.find(new WindowQuery().siteId(entity.getId()));
windowEntityList.forEach(item->item.setSiteName(entity.getSiteName()));
windowService.update(windowEntityList, context);
//更新站点业务名称 //更新站点业务名称
List<SiteBusinessEntity> siteBusinessEntities = siteBusinessService.find(new SiteBusinessQuery().siteId(entity.getId())); SiteBusinessEntity siteBusinessEntity = new SiteBusinessEntity();
siteBusinessEntities.forEach(item->item.setSiteName(entity.getSiteName())); siteBusinessEntity.setSiteName(newSite.getSiteName());
siteBusinessService.update(siteBusinessEntities, context); SiteBusinessEntity siteBusinessCondition = new SiteBusinessEntity();
siteBusinessCondition.setSiteName(oldSite.getSiteName());
//更新站点主题事项名称 siteBusinessService.updateBatch(siteBusinessEntity, siteBusinessCondition, context);
List<SiteMatterEntity> siteMatterEntities = siteMatterService.find(new SiteMatterQuery().siteId(entity.getId())); //更新站点事项名称
siteMatterEntities.forEach(item->item.setSiteName(entity.getSiteName())); SiteMatterEntity siteMatterEntity = new SiteMatterEntity();
siteMatterService.update(siteMatterEntities, context); siteMatterEntity.setSiteName(newSite.getSiteName());
SiteMatterEntity siteMatterCondition = new SiteMatterEntity();
siteMatterCondition.setSiteName(oldSite.getSiteName());
siteMatterService.updateBatch(siteMatterEntity, siteMatterCondition, context);
//更新站点主题事项名称 //更新站点主题事项名称
List<SiteThemeMatterEntity> siteThemeMatterEntities = siteThemeMatterService.find(new SiteThemeMatterQuery().siteId(entity.getId())); SiteThemeMatterEntity siteThemeMatterEntity = new SiteThemeMatterEntity();
siteThemeMatterEntities.forEach(item->item.setSiteName(entity.getSiteName())); siteThemeMatterEntity.setSiteName(newSite.getSiteName());
siteThemeMatterService.update(siteThemeMatterEntities, context); SiteThemeMatterEntity siteThemeMatterCondition = new SiteThemeMatterEntity();
siteThemeMatterCondition.setSiteName(oldSite.getSiteName());
siteThemeMatterService.updateBatch(siteThemeMatterEntity, siteThemeMatterCondition, context);
//更新工作人员站点 //更新工作人员站点
List<WorkmanEntity> workmanEntities = workmanService.find(new WorkmanQuery().siteId(entity.getId()));
workmanEntities.forEach(item->item.setSiteName(entity.getSiteName())); WorkmanEntity workmanEntity = new WorkmanEntity();
workmanService.update(workmanEntities, context);*/ workmanEntity.setSiteName(newSite.getSiteName());
WorkmanEntity workmanEntityCondition = new WorkmanEntity();
workmanEntityCondition.setSiteName(oldSite.getSiteName());
workmanService.updateBatch(workmanEntity, workmanEntityCondition, context);
} }
@Override @Override
...@@ -165,14 +174,18 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -165,14 +174,18 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
protected void saveBefore(SiteEntity entity, Context context) throws AppException { protected void saveBefore(SiteEntity entity, Context context) throws AppException {
List<SiteEntity> siteEntities = this.find(new SiteQuery().areaCode(entity.getAreaCode())); List<SiteEntity> siteEntities = this.find(new SiteQuery().areaCode(entity.getAreaCode()));
entity.setSiteCode(entity.getAreaCode() + Constant.SITE_SPLIT_MARK + StringUtils.lpad(siteEntities.size() + 1, Constant.SITE_CODE_NUM)); entity.setSiteCode(entity.getAreaCode() + Constant.SITE_SPLIT_MARK + StringUtils.lpad(siteEntities.size() + 1, Constant.SITE_CODE_NUM));
super.saveBefore(entity, context); super.saveBefore(entity, context);
} }
@Override @Override
protected void saveAfter(SiteEntity entity, Context context) throws AppException { protected void saveAfter(SiteEntity entity, Context context) throws AppException {
//刷新站点树 //刷新站点树
//ThreadPool.getInstance().execute(new SyncTreeSiteThread(this,context)); //ThreadPool.getInstance().execute(new SyncTreeSiteThread(this,context));
Rest<String> rest = userFeign.synchSiteAuth(); Rest<String> rest = userFeign.synchSiteAuth();
if (rest.getCode().equals(YesNoEnum.YES.getValue())) { if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
UserPdu userPdu = new UserPdu(); UserPdu userPdu = new UserPdu();
...@@ -181,14 +194,14 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -181,14 +194,14 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
Rest<RespData<List<UserPdu>>> list = userFeign.list(userPdu); Rest<RespData<List<UserPdu>>> list = userFeign.list(userPdu);
userService.updateUserList(list.getData().getData()); userService.updateUserList(list.getData().getData());
} }
//更新同步部门相关 //更新同步部门相关
deptService.syncDeptBySiteId(entity, context); deptService.syncDeptBySiteId(entity, context);
super.saveAfter(entity, context); super.saveAfter(entity, context);
} }
@Override @Override
public List<SiteTreeSelect> siteTree(Context context) { public List<SiteTreeSelect> siteTree(Context context) {
Map<String, AreaEntity> areaMap = new HashMap<>(); Map<String, AreaEntity> areaMap = new HashMap<>();
...@@ -310,7 +323,14 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -310,7 +323,14 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
Rest<RespData<List<UserPdu>>> list = userFeign.list(userPdu); Rest<RespData<List<UserPdu>>> list = userFeign.list(userPdu);
userService.updateUserList(list.getData().getData()); userService.updateUserList(list.getData().getData());
} }
if (refresh) {
//通知设备更新站点信息
DevicePdu devicePdu = new DevicePdu();
devicePdu.setSiteId(entity.getId());
Rest<Void> rest1 = deviceFeign.refreshMessage(devicePdu);
log.info("调用刷新结果:{}", JSON.toJSONString(rest1));
refresh = false;
}
super.updateAfter(entity, context); super.updateAfter(entity, context);
} }
...@@ -388,15 +408,15 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -388,15 +408,15 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
} }
@Override @Override
public Rest< List<SiteAreaVo>> getAreaSitesBySite(SiteQuery query, Context context) { public Rest<List<SiteAreaVo>> getAreaSitesBySite(SiteQuery query, Context context) {
List<SiteAreaVo> list = new ArrayList<>(); List<SiteAreaVo> list = new ArrayList<>();
//获取当前节点的第一层子节点 //获取当前节点的第一层子节点
if(ObjectUtils.isEmpty(query.getAreaName())){ if (ObjectUtils.isEmpty(query.getAreaName())) {
throw new AppException("区域名称查询参数不能为空!"); throw new AppException("区域名称查询参数不能为空!");
} }
//SiteEntity siteCache = this.getCache(query.getId().toString()); //SiteEntity siteCache = this.getCache(query.getId().toString());
AreaEntity areaEntity = areaService.selectOne(new AreaQuery().name(query.getAreaName()),context); AreaEntity areaEntity = areaService.selectOne(new AreaQuery().name(query.getAreaName()), context);
if(ObjectUtils.isEmpty(areaEntity)){ if (ObjectUtils.isEmpty(areaEntity)) {
throw new AppException("区域名称不存在!"); throw new AppException("区域名称不存在!");
} }
if ("False".equalsIgnoreCase(areaEntity.getHaveSonArea())) { if ("False".equalsIgnoreCase(areaEntity.getHaveSonArea())) {
...@@ -412,7 +432,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -412,7 +432,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
String matchCode = child.getAreaCode().replaceAll("(0)+$", ""); String matchCode = child.getAreaCode().replaceAll("(0)+$", "");
SiteQuery siteQuery = new SiteQuery(); SiteQuery siteQuery = new SiteQuery();
siteQuery.setAreaCode(matchCode + "%"); siteQuery.setAreaCode(matchCode + "%");
if(!ObjectUtils.isEmpty(query.getSiteName())){ if (!ObjectUtils.isEmpty(query.getSiteName())) {
siteQuery.setSiteName(query.getSiteName()); siteQuery.setSiteName(query.getSiteName());
} }
List<SiteEntity> siteEntities = this.find(siteQuery); List<SiteEntity> siteEntities = this.find(siteQuery);
...@@ -486,7 +506,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -486,7 +506,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Override @Override
public void changeUrlPath(SiteEntity siteEntity) { public void changeUrlPath(SiteEntity siteEntity) {
if (!ObjectUtils.isEmpty(siteEntity) && !ObjectUtils.isEmpty(siteEntity.getLogoPath())) { if (!ObjectUtils.isEmpty(siteEntity) && !ObjectUtils.isEmpty(siteEntity.getLogoPath())) {
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_IMAGE_URL, "http://192.168.0.98:11091"); String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091");
String fullPath = URLUtil.completeUrl(domain, siteEntity.getLogoPath()); String fullPath = URLUtil.completeUrl(domain, siteEntity.getLogoPath());
siteEntity.setLogoFullPath(fullPath); siteEntity.setLogoFullPath(fullPath);
} }
......
...@@ -19,4 +19,8 @@ public class SkinFieldVo extends BaseEntityLong { ...@@ -19,4 +19,8 @@ public class SkinFieldVo extends BaseEntityLong {
/** 结束 皮肤id */ /** 结束 皮肤id */
private Long skinIdEnd; private Long skinIdEnd;
//附件图片访问实际地址
private String fieldValueUrl;
} }
\ No newline at end of file
...@@ -11,6 +11,7 @@ import com.mortals.framework.model.PageInfo; ...@@ -11,6 +11,7 @@ import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.upload.service.UploadService; import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.FiletypeEnum;
import com.mortals.xhx.common.key.Constant; import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.utils.BeanUtil; import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.common.utils.FreeMarkerUtils; import com.mortals.xhx.common.utils.FreeMarkerUtils;
...@@ -79,22 +80,27 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk ...@@ -79,22 +80,27 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk
Map<String, String> imageResolutionMap = paramService.getParamBySecondOrganize("SkinBase", "imageResolution"); Map<String, String> imageResolutionMap = paramService.getParamBySecondOrganize("SkinBase", "imageResolution");
list.stream().forEach(item -> { list.stream().forEach(item -> {
List<SkinFieldEntity> skinFieldEntities = skinFieldService.find(new SkinFieldQuery().skinId(item.getId())); List<SkinFieldEntity> skinFieldEntities = skinFieldService.find(new SkinFieldQuery().skinId(item.getId()));
String domain = GlobalSysInfo.getParamValue(Constant.DOMAIN, "http://192.168.0.98:11071/");
skinFieldEntities.forEach(field -> {
if ("2".equals(field.getFieldType())) {
UrlBuilder builder = UrlBuilder.ofHttp(domain, CharsetUtil.CHARSET_UTF_8).addPath(field.getFieldValue());
field.setFieldValueUrl(builder.build());
}
});
ProductEntity productEntity = productService.get(item.getProductId()); ProductEntity productEntity = productService.get(item.getProductId());
item.setProductCode(productEntity == null ? "" : productEntity.getProductCode()); item.setProductCode(productEntity == null ? "" : productEntity.getProductCode());
item.setImageResolutionValue(imageResolutionMap.get(entity.getImageResolution() == null ? "1" : entity.getImageResolution())); item.setImageResolutionValue(imageResolutionMap.get(entity.getImageResolution() == null ? "1" : entity.getImageResolution()));
item.setSkinFieldList(skinFieldEntities); item.setSkinFieldList(skinFieldEntities);
String domain = GlobalSysInfo.getParamValue(Constant.DOMAIN, "http://192.168.0.98:11071/");
if (!ObjectUtils.isEmpty(item.getPreviewImagePath())) { if (!ObjectUtils.isEmpty(item.getPreviewImagePath())) {
UrlBuilder builder = UrlBuilder.ofHttp(domain, CharsetUtil.CHARSET_UTF_8).addPath(item.getPreviewImagePath()); UrlBuilder builder = UrlBuilder.ofHttp(domain, CharsetUtil.CHARSET_UTF_8).addPath(item.getPreviewImagePath());
item.setPreviewImagePath(builder.build()); item.setPreviewImagePath(builder.build());
log.info("cssUrl:" + URLDecoder.decode(item.getPreviewImagePath(), CharsetUtil.CHARSET_UTF_8)); //log.info("cssUrl:" + URLDecoder.decode(item.getPreviewImagePath(), CharsetUtil.CHARSET_UTF_8));
} }
if (!ObjectUtils.isEmpty(item.getCssFilePath())) { if (!ObjectUtils.isEmpty(item.getCssFilePath())) {
UrlBuilder builder = UrlBuilder.ofHttp(domain, CharsetUtil.CHARSET_UTF_8).addPath(item.getCssFilePath()); UrlBuilder builder = UrlBuilder.ofHttp(domain, CharsetUtil.CHARSET_UTF_8).addPath(item.getCssFilePath());
item.setCssFilePath(builder.build()); item.setCssFilePath(builder.build());
log.info("cssUrl:" + URLDecoder.decode(item.getCssFilePath(), CharsetUtil.CHARSET_UTF_8)); //log.info("cssUrl:" + URLDecoder.decode(item.getCssFilePath(), CharsetUtil.CHARSET_UTF_8));
} }
}); });
super.findAfter(entity, pageInfo, context, list); super.findAfter(entity, pageInfo, context, list);
......
package com.mortals.xhx.module.window.service.impl; package com.mortals.xhx.module.window.service.impl;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
...@@ -34,12 +35,12 @@ import static com.mortals.framework.util.HttpUtil.HEADER_CONTENT_TYPE; ...@@ -34,12 +35,12 @@ import static com.mortals.framework.util.HttpUtil.HEADER_CONTENT_TYPE;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_PHP_HTTP_URL; import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_PHP_HTTP_URL;
/** /**
* WindowBusinessService * WindowBusinessService
* 窗口业务 service实现 * 窗口业务 service实现
* *
* @author zxfei * @author zxfei
* @date 2022-01-12 * @date 2022-01-12
*/ */
@Service("windowBusinessService") @Service("windowBusinessService")
@Slf4j @Slf4j
public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBusinessDao, WindowBusinessEntity, Long> implements WindowBusinessService { public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBusinessDao, WindowBusinessEntity, Long> implements WindowBusinessService {
...@@ -50,11 +51,11 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus ...@@ -50,11 +51,11 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
protected void findAfter(WindowBusinessEntity entity, PageInfo pageInfo, Context context, List<WindowBusinessEntity> list) throws AppException { protected void findAfter(WindowBusinessEntity entity, PageInfo pageInfo, Context context, List<WindowBusinessEntity> list) throws AppException {
Map<Long, WindowEntity> collect = windowService.findToMap(new WindowQuery(), context); Map<Long, WindowEntity> collect = windowService.findToMap(new WindowQuery(), context);
Iterator iterator = list.iterator(); Iterator iterator = list.iterator();
while (iterator.hasNext()){ while (iterator.hasNext()) {
WindowBusinessEntity item = (WindowBusinessEntity) iterator.next(); WindowBusinessEntity item = (WindowBusinessEntity) iterator.next();
if(!ObjectUtils.isEmpty(item.getWindowId())&&!ObjectUtils.isEmpty(collect.get(item.getWindowId()))){ if (!ObjectUtils.isEmpty(item.getWindowId()) && !ObjectUtils.isEmpty(collect.get(item.getWindowId()))) {
item.setFromnum(collect.get(item.getWindowId()).getFromnum()); item.setFromnum(collect.get(item.getWindowId()).getFromnum());
}else { } else {
iterator.remove(); iterator.remove();
} }
} }
...@@ -62,6 +63,21 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus ...@@ -62,6 +63,21 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
} }
/**
* @param ids
* @param context
* @throws AppException
*/
@Override
protected void removeBefore(Long[] ids, Context context) throws AppException {
Arrays.asList(ids).forEach(id -> {
WindowBusinessEntity windowBusinessEntity = this.get(id, context);
pushChangeMsg(windowBusinessEntity);
});
super.removeBefore(ids, context);
}
/** /**
* @param entity * @param entity
* @param context * @param context
...@@ -75,7 +91,6 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus ...@@ -75,7 +91,6 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
} }
/** /**
* @param entity * @param entity
* @param context * @param context
...@@ -89,10 +104,10 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus ...@@ -89,10 +104,10 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
private void pushChangeMsg(WindowBusinessEntity entity) { private void pushChangeMsg(WindowBusinessEntity entity) {
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090"); String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
phpUrl+="/api/window/winNameChange"; phpUrl += "/api/window/winNameChange";
HashMap<String, Object> paramsMap = new HashMap<>(); HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("windowid", entity.getWindowId()); paramsMap.put("windowid", entity.getWindowId());
paramsMap.put("typeinfo",1); paramsMap.put("typeinfo", 1);
String resp = null; String resp = null;
try { try {
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
......
...@@ -13,6 +13,7 @@ import com.mortals.xhx.module.window.dao.WindowMatterDao; ...@@ -13,6 +13,7 @@ import com.mortals.xhx.module.window.dao.WindowMatterDao;
import com.mortals.xhx.module.window.model.WindowMatterEntity; import com.mortals.xhx.module.window.model.WindowMatterEntity;
import com.mortals.xhx.module.window.service.WindowMatterService; import com.mortals.xhx.module.window.service.WindowMatterService;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -40,6 +41,32 @@ public class WindowMatterServiceImpl extends AbstractCRUDServiceImpl<WindowMatte ...@@ -40,6 +41,32 @@ public class WindowMatterServiceImpl extends AbstractCRUDServiceImpl<WindowMatte
super.saveAfter(entity, context); super.saveAfter(entity, context);
} }
/**
* @param id
* @param context
* @throws AppException
*/
@Override
protected void removeBefore(Long id, Context context) throws AppException {
WindowMatterEntity windowMatterEntity = this.get(id, context);
pushChangeMsg(windowMatterEntity);
super.removeBefore(id, context);
}
/**
* @param ids
* @param context
* @throws AppException
*/
@Override
protected void removeBefore(Long[] ids, Context context) throws AppException {
Arrays.asList(ids).forEach(id->{
WindowMatterEntity windowMatterEntity = this.get(id, context);
pushChangeMsg(windowMatterEntity);
});
super.removeBefore(ids, context);
}
/** /**
* @param entity * @param entity
* @param context * @param context
......
...@@ -142,6 +142,10 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W ...@@ -142,6 +142,10 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W
List<WindowMatterEntity> windowMatterEntities = windowMatterService.find(windowMatterQuery); List<WindowMatterEntity> windowMatterEntities = windowMatterService.find(windowMatterQuery);
windowMatterService.removeList(windowMatterEntities, context); windowMatterService.removeList(windowMatterEntities, context);
} }
Arrays.asList(ids).forEach(id -> {
pushChangeMsg(id);
});
super.removeAfter(ids, context, result); super.removeAfter(ids, context, result);
} }
...@@ -154,7 +158,7 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W ...@@ -154,7 +158,7 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W
@Override @Override
protected void updateAfter(WindowEntity entity, Context context) throws AppException { protected void updateAfter(WindowEntity entity, Context context) throws AppException {
super.updateAfter(entity, context); super.updateAfter(entity, context);
pushChangeMsg(entity); pushChangeMsg(entity.getId());
} }
/** /**
...@@ -165,18 +169,18 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W ...@@ -165,18 +169,18 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W
@Override @Override
protected void saveAfter(WindowEntity entity, Context context) throws AppException { protected void saveAfter(WindowEntity entity, Context context) throws AppException {
super.saveAfter(entity, context); super.saveAfter(entity, context);
pushChangeMsg(entity); pushChangeMsg(entity.getId());
} }
private void pushChangeMsg(WindowEntity entity) { private void pushChangeMsg(Long windowId) {
log.info("pushChangeMsg:{}",JSON.toJSONString(entity)); log.info("pushChangeMsg:{}", JSON.toJSONString(windowId));
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090"); String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
phpUrl+="/api/window/winNameChange"; phpUrl += "/api/window/winNameChange";
HashMap<String, Object> paramsMap = new HashMap<>(); HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("windowid", entity.getId()); paramsMap.put("windowid", windowId);
paramsMap.put("typeinfo",1); paramsMap.put("typeinfo", 1);
phpUrl+="/api/window/winNameChange"; phpUrl += "/api/window/winNameChange";
String resp = null; String resp = null;
try { try {
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
......
...@@ -66,7 +66,7 @@ public class WindowMatterController extends BaseCRUDJsonBodyMappingController<Wi ...@@ -66,7 +66,7 @@ public class WindowMatterController extends BaseCRUDJsonBodyMappingController<Wi
*/ */
@Override @Override
protected int saveAfter(WindowMatterEntity entity, Map<String, Object> model, Context context) throws AppException { protected int saveAfter(WindowMatterEntity entity, Map<String, Object> model, Context context) throws AppException {
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://10.12.185.213:8090"); String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
HashMap<String, Object> paramsMap = new HashMap<>(); HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("windowid", entity.getWindowId()); paramsMap.put("windowid", entity.getWindowId());
String resp = null; String resp = null;
...@@ -81,4 +81,15 @@ public class WindowMatterController extends BaseCRUDJsonBodyMappingController<Wi ...@@ -81,4 +81,15 @@ public class WindowMatterController extends BaseCRUDJsonBodyMappingController<Wi
} }
return super.saveAfter(entity, model, context); return super.saveAfter(entity, model, context);
} }
/**
* @param ids
* @param context
* @throws AppException
*/
@Override
protected void deleteBefore(Long[] ids, Context context) throws AppException {
super.deleteBefore(ids, context);
}
} }
\ No newline at end of file
...@@ -15,6 +15,7 @@ import com.mortals.xhx.module.workman.dao.WorkmanDao; ...@@ -15,6 +15,7 @@ import com.mortals.xhx.module.workman.dao.WorkmanDao;
import com.mortals.xhx.module.workman.model.WorkmanEntity; import com.mortals.xhx.module.workman.model.WorkmanEntity;
import com.mortals.xhx.module.workman.model.WorkmanQuery; import com.mortals.xhx.module.workman.model.WorkmanQuery;
import com.mortals.xhx.module.workman.service.WorkmanService; import com.mortals.xhx.module.workman.service.WorkmanService;
import com.mortals.xhx.utils.EncodeUtil;
import lombok.Getter; import lombok.Getter;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
...@@ -53,7 +54,6 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao, ...@@ -53,7 +54,6 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
@Override @Override
protected void saveBefore(WorkmanEntity entity, Context context) throws AppException { protected void saveBefore(WorkmanEntity entity, Context context) throws AppException {
if (StringUtils.isNull(entity.getLoginName())) { if (StringUtils.isNull(entity.getLoginName())) {
throw new AppException("账号不能为空!"); throw new AppException("账号不能为空!");
} }
...@@ -61,8 +61,8 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao, ...@@ -61,8 +61,8 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
if (StringUtils.isNull(entity.getLoginPwd())) { if (StringUtils.isNull(entity.getLoginPwd())) {
throw new AppException("密码不能为空!"); throw new AppException("密码不能为空!");
} }
List<WorkmanEntity> list = this.find(new WorkmanQuery().loginName(entity.getLoginName())); int count = this.count(new WorkmanQuery().loginName(entity.getLoginName()),context);
if (CollectionUtils.isNotEmpty(list)) { if (count>0) {
throw new AppException("账号已存在!"); throw new AppException("账号已存在!");
} }
...@@ -152,7 +152,13 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao, ...@@ -152,7 +152,13 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
throw new AppException("文件不存在!"); throw new AppException("文件不存在!");
} }
//解压图片 //解压图片
ZipUtil.unzip(targetFilePath, disPath, Charset.forName("GBK")); String fileEncode ="UTF-8";
try {
fileEncode = EncodeUtil.getEncode(targetFilePath,true);
} catch (Exception e) {
log.error("异常",e);
}
ZipUtil.unzip(targetFilePath, disPath, Charset.forName(fileEncode));
//读取目录下的所有图片 //读取目录下的所有图片
File[] files = FileUtil.ls(disPath); File[] files = FileUtil.ls(disPath);
for (File file : files) { for (File file : files) {
......
package com.mortals.xhx.module.workman.web; package com.mortals.xhx.module.workman.web;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.pinyin.PinyinUtil; import cn.hutool.extra.pinyin.PinyinUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
...@@ -187,7 +188,8 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman ...@@ -187,7 +188,8 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman
workmanEntity.setLoginName(loginName); workmanEntity.setLoginName(loginName);
} }
if (ObjectUtils.isEmpty(workmanEntity.getLoginPwd())) { log.info("loginPwd:"+workmanEntity.getLoginPwd());
if (ObjectUtils.isEmpty(workmanEntity.getLoginPwd())||"".equals(workmanEntity.getLoginPwd().trim())) {
workmanEntity.setLoginPwd("123"); workmanEntity.setLoginPwd("123");
} }
...@@ -222,6 +224,12 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman ...@@ -222,6 +224,12 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(StrUtil.cleanBlank(PinyinUtil.getPinyin("张 三", ""))); System.out.println(StrUtil.cleanBlank(PinyinUtil.getPinyin("张 三", "")));
//
// System.out.println(Base64.encode(new JSONObject().toJSONString()));
// System.out.println( com.mortals.framework.util.Base64.encode(new JSONObject().toJSONString().getBytes()));
//
//
System.out.println(Base64.encode("[]"));
} }
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
<if test="condition.matterName != null and condition.matterName != ''"> <if test="condition.matterName != null and condition.matterName != ''">
and a.matterName like #{condition.matterName} and a.matterName like #{condition.matterName}
</if> </if>
<if test="condition.source!=null and condition.source!=''">
and a.source = #{condition.source,jdbcType=VARCHAR}
</if>
</trim> </trim>
</trim> </trim>
</select> </select>
...@@ -55,6 +58,9 @@ ...@@ -55,6 +58,9 @@
<if test="condition.matterName != null and condition.matterName != ''"> <if test="condition.matterName != null and condition.matterName != ''">
and a.matterName like #{condition.matterName} and a.matterName like #{condition.matterName}
</if> </if>
<if test="condition.source!=null and condition.source!=''">
and a.source = #{condition.source,jdbcType=VARCHAR}
</if>
</trim> </trim>
</trim> </trim>
</select> </select>
......
package com.mortals.xhx.utils;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.BitSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author 自动识别文件编码格式
*/
public class EncodeUtil {
private static Logger logger = LoggerFactory.getLogger(EncodeUtil.class);
private static int BYTE_SIZE = 8;
public static String CODE_UTF8 = "UTF-8";
public static String CODE_UTF8_BOM = "UTF-8_BOM";
public static String CODE_GBK = "GBK";
/**
* 通过文件全名称获取编码集名称
*
* @param fullFileName
* @param ignoreBom
* @return
* @throws Exception
*/
public static String getEncode(String fullFileName, boolean ignoreBom) throws Exception {
logger.debug("fullFileName ; {}", fullFileName);
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fullFileName));
return getEncode(bis, ignoreBom);
}
/**
* 通过文件缓存流获取编码集名称,文件流必须为未曾
*
* @param bis
* @param ignoreBom 是否忽略utf-8 bom
* @return
* @throws Exception
*/
public static String getEncode(BufferedInputStream bis, boolean ignoreBom) throws Exception {
bis.mark(0);
String encodeType = "未识别";
byte[] head = new byte[3];
bis.read(head);
if (head[0] == -1 && head[1] == -2) {
encodeType = "UTF-16";
} else if (head[0] == -2 && head[1] == -1) {
encodeType = "Unicode";
} else if (head[0] == -17 && head[1] == -69 && head[2] == -65) { //带BOM
if (ignoreBom) {
encodeType = CODE_UTF8;
} else {
encodeType = CODE_UTF8_BOM;
}
} else if ("Unicode".equals(encodeType)) {
encodeType = "UTF-16";
} else if (isUTF8(bis)) {
encodeType = CODE_UTF8;
} else {
encodeType = CODE_GBK;
}
logger.info("result encode type : " + encodeType);
return encodeType;
}
/**
* 是否是无BOM的UTF8格式,不判断常规场景,只区分无BOM UTF8和GBK
*
* @param bis
* @return
*/
private static boolean isUTF8(BufferedInputStream bis) throws Exception {
bis.reset();
//读取第一个字节
int code = bis.read();
do {
BitSet bitSet = convert2BitSet(code);
//判断是否为单字节
if (bitSet.get(0)) {//多字节时,再读取N个字节
if (!checkMultiByte(bis, bitSet)) {//未检测通过,直接返回
return false;
}
} else {
//单字节时什么都不用做,再次读取字节
}
code = bis.read();
} while (code != -1);
return true;
}
/**
* 检测多字节,判断是否为utf8,已经读取了一个字节
*
* @param bis
* @param bitSet
* @return
*/
private static boolean checkMultiByte(BufferedInputStream bis, BitSet bitSet) throws Exception {
int count = getCountOfSequential(bitSet);
byte[] bytes = new byte[count - 1];//已经读取了一个字节,不能再读取
bis.read(bytes);
for (byte b : bytes) {
if (!checkUtf8Byte(b)) {
return false;
}
}
return true;
}
/**
* 检测单字节,判断是否为utf8
*
* @param b
* @return
*/
private static boolean checkUtf8Byte(byte b) throws Exception {
BitSet bitSet = convert2BitSet(b);
return bitSet.get(0) && !bitSet.get(1);
}
/**
* 检测bitSet中从开始有多少个连续的1
*
* @param bitSet
* @return
*/
private static int getCountOfSequential(BitSet bitSet) {
int count = 0;
for (int i = 0; i < BYTE_SIZE; i++) {
if (bitSet.get(i)) {
count++;
} else {
break;
}
}
return count;
}
/**
* 将整形转为BitSet
*
* @param code
* @return
*/
private static BitSet convert2BitSet(int code) {
BitSet bitSet = new BitSet(BYTE_SIZE);
for (int i = 0; i < BYTE_SIZE; i++) {
int tmp3 = code >> (BYTE_SIZE - i - 1);
int tmp2 = 0x1 & tmp3;
if (tmp2 == 1) {
bitSet.set(i);
}
}
return bitSet;
}
/**
* 将一指定编码的文件转换为另一编码的文件
*
* @param oldFullFileName
* @param oldCharsetName
* @param newFullFileName
* @param newCharsetName
*/
public static void convert(String oldFullFileName, String oldCharsetName, String newFullFileName, String newCharsetName) throws Exception {
logger.info("the old file name is : {}, The oldCharsetName is : {}", oldFullFileName, oldCharsetName);
logger.info("the new file name is : {}, The newCharsetName is : {}", newFullFileName, newCharsetName);
StringBuffer content = new StringBuffer();
BufferedReader bin = new BufferedReader(new InputStreamReader(new FileInputStream(oldFullFileName), oldCharsetName));
String line;
while ((line = bin.readLine()) != null) {
content.append(line);
content.append(System.getProperty("line.separator"));
}
newFullFileName = newFullFileName.replace("\\", "/");
File dir = new File(newFullFileName.substring(0, newFullFileName.lastIndexOf("/")));
if (!dir.exists()) {
dir.mkdirs();
}
Writer out = new OutputStreamWriter(new FileOutputStream(newFullFileName), newCharsetName);
out.write(content.toString());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment