Commit 51645fc6 authored by 赵啸非's avatar 赵啸非

修改根据业务查询部门逻辑

parent b455a3bc
package com.mortals.xhx.base.framework.filter;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.mortals.framework.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.web.util.WebUtils;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.*;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
@Slf4j
public class RepeatReadHttpRequest extends HttpServletRequestWrapper {
private final ByteArrayOutputStream cachedContent;
private Map<String, String[]> cachedForm;
private ServletInputStream inputStream;
public RepeatReadHttpRequest(HttpServletRequest request) {
super(request);
this.cachedContent = new ByteArrayOutputStream();
this.cachedForm = new HashMap<>();
cacheData();
}
@Override
public ServletInputStream getInputStream() throws IOException {
this.inputStream = new RepeatReadInputStream(cachedContent.toByteArray());
return this.inputStream;
}
@Override
public String getCharacterEncoding() {
String enc = super.getCharacterEncoding();
return (enc != null ? enc : WebUtils.DEFAULT_CHARACTER_ENCODING);
}
@Override
public BufferedReader getReader() throws IOException {
return new BufferedReader(new InputStreamReader(getInputStream(), getCharacterEncoding()));
}
@Override
public String getParameter(String name) {
String value = null;
if (isFormPost()) {
String[] values = cachedForm.get(name);
if (null != values && values.length > 0) {
value = values[0];
}
}
if (StringUtils.isEmpty(value)) {
value = super.getParameter(name);
}
return value;
}
@Override
public Map<String, String[]> getParameterMap() {
if (isFormPost() && !CollectionUtils.sizeIsEmpty(cachedForm)) {
return cachedForm;
}
return super.getParameterMap();
}
@Override
public Enumeration<String> getParameterNames() {
if (isFormPost() && !CollectionUtils.sizeIsEmpty(cachedForm)) {
return Collections.enumeration(cachedForm.keySet());
}
return super.getParameterNames();
}
@Override
public String[] getParameterValues(String name) {
if (isFormPost() && !CollectionUtils.sizeIsEmpty(cachedForm)) {
return cachedForm.get(name);
}
return super.getParameterValues(name);
}
private void cacheData() {
try {
if (isFormPost()) {
this.cachedForm = super.getParameterMap();
} else {
ServletInputStream inputStream = super.getInputStream();
IOUtils.copy(inputStream, this.cachedContent);
}
} catch (IOException e) {
log.warn("[RepeatReadHttpRequest:cacheData], error: {}", e.getMessage());
}
}
private boolean isFormPost() {
String contentType = getContentType();
return (contentType != null &&
(contentType.contains(MediaType.APPLICATION_FORM_URLENCODED_VALUE) ||
contentType.contains(MediaType.MULTIPART_FORM_DATA_VALUE)) &&
HttpMethod.POST.matches(getMethod()));
}
private static class RepeatReadInputStream extends ServletInputStream {
private final ByteArrayInputStream inputStream;
public RepeatReadInputStream(byte[] bytes) {
this.inputStream = new ByteArrayInputStream(bytes);
}
@Override
public int read() throws IOException {
return this.inputStream.read();
}
@Override
public int readLine(byte[] b, int off, int len) throws IOException {
return this.inputStream.read(b, off, len);
}
@Override
public boolean isFinished() {
return this.inputStream.available() == 0;
}
@Override
public boolean isReady() {
return true;
}
@Override
public void setReadListener(ReadListener listener) {
}
}
}
\ No newline at end of file
...@@ -63,8 +63,6 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L ...@@ -63,8 +63,6 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L
private AppInfoTempleteFieldService appInfoTempleteFieldService; private AppInfoTempleteFieldService appInfoTempleteFieldService;
@Autowired @Autowired
private AppVersionService appVersionService; private AppVersionService appVersionService;
@Override @Override
protected void findAfter(AppEntity params, PageInfo pageInfo, Context context, List<AppEntity> list) throws AppException { protected void findAfter(AppEntity params, PageInfo pageInfo, Context context, List<AppEntity> list) throws AppException {
//排序 //排序
......
...@@ -52,14 +52,12 @@ public class AppController extends BaseCRUDJsonBodyMappingController<AppService, ...@@ -52,14 +52,12 @@ public class AppController extends BaseCRUDJsonBodyMappingController<AppService,
@Override @Override
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "type", AppTypeEnum.getEnumMap()); this.addDict(model, "type", AppTypeEnum.getEnumMap());
this.addDict(model, "shelves", paramService.getParamBySecondOrganize("App", "shelves")); this.addDict(model, "shelves", paramService.getParamBySecondOrganize("App", "shelves"));
this.addDict(model, "distribute", YesNoEnum.getEnumMap()); this.addDict(model, "distribute", YesNoEnum.getEnumMap());
this.addDict(model, "dateUpdate", YesNoEnum.getEnumMap()); this.addDict(model, "dateUpdate", YesNoEnum.getEnumMap());
super.init(model, context); super.init(model, context);
} }
@Override @Override
protected int infoAfter(Long id, Map<String, Object> model, AppEntity entity, Context context) throws AppException { protected int infoAfter(Long id, Map<String, Object> model, AppEntity entity, Context context) throws AppException {
List<AppEntity> appEntityList = this.service.find(new AppQuery().appCode(entity.getAppCode()), context); List<AppEntity> appEntityList = this.service.find(new AppQuery().appCode(entity.getAppCode()), context);
......
...@@ -11,6 +11,7 @@ import com.mortals.framework.exception.AppException; ...@@ -11,6 +11,7 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.util.DataUtil; import com.mortals.framework.util.DataUtil;
import com.mortals.xhx.base.framework.config.InterceptorConfig; import com.mortals.xhx.base.framework.config.InterceptorConfig;
...@@ -38,6 +39,7 @@ import com.mortals.xhx.module.site.service.SiteThemeMatterService; ...@@ -38,6 +39,7 @@ import com.mortals.xhx.module.site.service.SiteThemeMatterService;
import com.mortals.xhx.module.site.service.SiteThemeService; import com.mortals.xhx.module.site.service.SiteThemeService;
import com.mortals.xhx.module.window.model.WindowMatterQuery; import com.mortals.xhx.module.window.model.WindowMatterQuery;
import com.mortals.xhx.module.window.service.WindowMatterService; import com.mortals.xhx.module.window.service.WindowMatterService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
...@@ -58,8 +60,8 @@ import java.util.stream.Collectors; ...@@ -58,8 +60,8 @@ import java.util.stream.Collectors;
* @date 2022-01-12 * @date 2022-01-12
*/ */
@Service("matterService") @Service("matterService")
public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, MatterEntity, Long> implements MatterService { @Slf4j
protected Log log = LogFactory.getLog(this.getClass()); public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, MatterEntity, Long> implements MatterService {
@Autowired @Autowired
private SiteMatterService siteMatterService; private SiteMatterService siteMatterService;
@Autowired @Autowired
......
...@@ -19,11 +19,6 @@ public class SiteMatterVo extends BaseEntityLong { ...@@ -19,11 +19,6 @@ public class SiteMatterVo extends BaseEntityLong {
*/ */
private String belongDept; private String belongDept;
/**
* 部门编号
*/
private String deptCode;
/** /**
* 窗口到现场次数 * 窗口到现场次数
*/ */
...@@ -34,4 +29,9 @@ public class SiteMatterVo extends BaseEntityLong { ...@@ -34,4 +29,9 @@ public class SiteMatterVo extends BaseEntityLong {
*/ */
private Integer onlineToTheSceneNum; private Integer onlineToTheSceneNum;
/**
* 区域编码
*/
private String areaCode;
} }
\ No newline at end of file
...@@ -40,6 +40,7 @@ public class SiteMatterServiceImpl extends AbstractCRUDServiceImpl<SiteMatterDao ...@@ -40,6 +40,7 @@ public class SiteMatterServiceImpl extends AbstractCRUDServiceImpl<SiteMatterDao
item.setWindowToTheSceneNum(matterEntity.getWindowToTheSceneNum()); item.setWindowToTheSceneNum(matterEntity.getWindowToTheSceneNum());
item.setOnlineToTheSceneNum(matterEntity.getOnlineToTheSceneNum()); item.setOnlineToTheSceneNum(matterEntity.getOnlineToTheSceneNum());
item.setDeptCode(matterEntity.getDeptCode()); item.setDeptCode(matterEntity.getDeptCode());
item.setAreaCode(matterEntity.getAreaCode());
} }
} }
}); });
......
...@@ -202,7 +202,7 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao, ...@@ -202,7 +202,7 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
//根据用户名查询工作人员名称 //根据用户名查询工作人员名称
WorkmanEntity workmanEntity = workmanService.selectOne(new WorkmanQuery().name(userName)); WorkmanEntity workmanEntity = workmanService.selectOne(new WorkmanQuery().name(userName));
if (!ObjectUtils.isEmpty(workmanEntity)) { if (!ObjectUtils.isEmpty(workmanEntity)) {
String newName = "/file/uploadfile/" + new Date().getTime() + "." + FileUtil.getSuffix(file); String newName = "/file/fileupload/" + new Date().getTime() + "." + FileUtil.getSuffix(file);
String filePath = uploadService.getFilePath(newName); String filePath = uploadService.getFilePath(newName);
try { try {
boolean bool = com.mortals.framework.util.FileUtil.write(filePath, FileUtil.readBytes(file), true, true); boolean bool = com.mortals.framework.util.FileUtil.write(filePath, FileUtil.readBytes(file), true, true);
......
...@@ -225,7 +225,7 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman ...@@ -225,7 +225,7 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman
if (!ObjectUtils.isEmpty(workmanEntity.getPicObj())) { if (!ObjectUtils.isEmpty(workmanEntity.getPicObj())) {
String extension = workmanEntity.getPicObj().suggestFileExtension(); String extension = workmanEntity.getPicObj().suggestFileExtension();
String newName = "/file/uploadfile/" + new Date().getTime() + "." + extension; String newName = "/file/fileupload/" + new Date().getTime() + "." + extension;
String filePath = uploadService.getFilePath(newName); String filePath = uploadService.getFilePath(newName);
try { try {
boolean bool = FileUtil.write(filePath, workmanEntity.getPicObj().getData(), true, true); boolean bool = FileUtil.write(filePath, workmanEntity.getPicObj().getData(), true, true);
......
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