Commit 4aea065c authored by 赵啸非's avatar 赵啸非

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

parent b2a9449a
package com.mortals.xhx.base.framework.config; package com.mortals.xhx.base.framework.config;
import com.alibaba.fastjson.parser.ParserConfig;
import com.mortals.xhx.module.site.model.SiteTreeSelect;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
...@@ -18,6 +20,8 @@ public class CorsConfig implements WebMvcConfigurer { ...@@ -18,6 +20,8 @@ public class CorsConfig implements WebMvcConfigurer {
@Bean @Bean
public CorsFilter corsFilter(){ public CorsFilter corsFilter(){
ParserConfig.getGlobalInstance().putDeserializer(SiteTreeSelect.class, new SiteTreeSelect.Deserializer());
//初始化配置对象 //初始化配置对象
CorsConfiguration configuration = new CorsConfiguration(); CorsConfiguration configuration = new CorsConfiguration();
//允许跨域访问的域名 //允许跨域访问的域名
......
...@@ -137,4 +137,8 @@ public final class Constant { ...@@ -137,4 +137,8 @@ public final class Constant {
public final static String CUSTAPP_ROOT_PATH = "app"; public final static String CUSTAPP_ROOT_PATH = "app";
public final static String USER_SITE_TREE = "user:site:tree";
} }
...@@ -47,6 +47,14 @@ public class DemoStartedService implements IApplicationStartedService { ...@@ -47,6 +47,14 @@ public class DemoStartedService implements IApplicationStartedService {
SyncTreeSiteThread syncTreeSiteThread = new SyncTreeSiteThread(contextTemp); SyncTreeSiteThread syncTreeSiteThread = new SyncTreeSiteThread(contextTemp);
ThreadPool.getInstance().execute(syncTreeSiteThread); ThreadPool.getInstance().execute(syncTreeSiteThread);
userEntity = new UserEntity();
userEntity.initAttrValue();
userEntity.setId(1L);
contextTemp = new Context();
contextTemp.setUser(userEntity);
syncTreeSiteThread = new SyncTreeSiteThread(contextTemp);
ThreadPool.getInstance().execute(syncTreeSiteThread);
/* userService.find(new UserQuery()).forEach(user->{ /* userService.find(new UserQuery()).forEach(user->{
Context context = new Context(); Context context = new Context();
......
...@@ -30,26 +30,25 @@ import java.util.List; ...@@ -30,26 +30,25 @@ import java.util.List;
@Service("SyncUserTask") @Service("SyncUserTask")
public class SyncUserTaskImpl implements ITaskExcuteService { public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
private ResourceService resourceService;
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired @Autowired
private IUserFeign userFeign; private IUserFeign userFeign;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
log.info("同步用户");
UserPdu userPdu = new UserPdu(); UserPdu userPdu = new UserPdu();
userPdu.setPage(1); userPdu.setPage(1);
userPdu.setSize(-1); userPdu.setSize(-1);
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());
//resourceService.updateUserList(); //resourceService.updateUserList();
/* UserPdu userPdu = new UserPdu(); /* UserPdu userPdu = new UserPdu();
......
...@@ -111,7 +111,6 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa ...@@ -111,7 +111,6 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa
List<Long> businessIdList = Arrays.asList(businessIds.split(",")).stream().map(Long::parseLong).collect(Collectors.toList()); List<Long> businessIdList = Arrays.asList(businessIds.split(",")).stream().map(Long::parseLong).collect(Collectors.toList());
//先删除后再新增 //先删除后再新增
SiteBusinessQuery siteBusinessQuery = new SiteBusinessQuery(); SiteBusinessQuery siteBusinessQuery = new SiteBusinessQuery();
siteBusinessQuery.setSiteId(siteId); siteBusinessQuery.setSiteId(siteId);
siteBusinessQuery.setBusinessIdList(businessIdList); siteBusinessQuery.setBusinessIdList(businessIdList);
...@@ -136,7 +135,6 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa ...@@ -136,7 +135,6 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa
} }
private void updateOrSave(BusinessEntity item, Long siteId, Context context) { private void updateOrSave(BusinessEntity item, Long siteId, Context context) {
SiteBusinessEntity siteBusinessEntity = new SiteBusinessEntity(); SiteBusinessEntity siteBusinessEntity = new SiteBusinessEntity();
BeanUtils.copyProperties(item, siteBusinessEntity, BeanUtil.getNullPropertyNames(item)); BeanUtils.copyProperties(item, siteBusinessEntity, BeanUtil.getNullPropertyNames(item));
SiteEntity siteEntity = siteService.get(siteId); SiteEntity siteEntity = siteService.get(siteId);
......
package com.mortals.xhx.module.site.model; package com.mortals.xhx.module.site.model;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import com.mortals.xhx.module.area.model.AreaEntity; import com.mortals.xhx.module.area.model.AreaEntity;
import lombok.Data; import lombok.Data;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -67,6 +74,9 @@ public class SiteTreeSelect implements Serializable { ...@@ -67,6 +74,9 @@ public class SiteTreeSelect implements Serializable {
*/ */
private List<SiteTreeSelect> children; private List<SiteTreeSelect> children;
public SiteTreeSelect() {
}
public SiteTreeSelect(AreaEntity entity) { public SiteTreeSelect(AreaEntity entity) {
//如果是站点,则替换名称和id //如果是站点,则替换名称和id
...@@ -113,16 +123,35 @@ public class SiteTreeSelect implements Serializable { ...@@ -113,16 +123,35 @@ public class SiteTreeSelect implements Serializable {
} }
public SiteTreeSelect(SiteEntity entity) { // 反序列化器
this.id = entity.getId().toString(); public static class Deserializer implements ObjectDeserializer {
this.label = entity.getSiteName(); @Override
this.isLeaf = true; public SiteTreeSelect deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
this.type = "site"; SiteTreeSelect node = new SiteTreeSelect();
this.icon = "el-icon-document"; JSONObject jsonObject = parser.parseObject();
node.setId(jsonObject.getString("id"));
this.longitude = entity.getLongitude(); node.setSiteCode(jsonObject.getString("siteCode"));
this.latitude = entity.getLatitude(); node.setLabel(jsonObject.getString("label"));
node.setAreaCode(jsonObject.getString("areacode"));
node.setIsLeaf(jsonObject.getBoolean("isLeaf"));
node.setLongitude(jsonObject.getString("longitude"));
node.setLatitude(jsonObject.getString("latitude"));
node.setType(jsonObject.getString("type"));
node.setIcon(jsonObject.getString("icon"));
JSONArray jsonArray = jsonObject.getJSONArray("children");
List<SiteTreeSelect> children = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
SiteTreeSelect child = JSON.parseObject(jsonArray.getJSONObject(i).toJSONString(), SiteTreeSelect.class);
children.add(child);
}
node.setChildren(children);
return node;
}
@Override
public int getFastMatchToken() {
return JSONToken.LBRACE;
}
} }
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ import cn.hutool.core.collection.ListUtil; ...@@ -4,6 +4,7 @@ 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 cn.hutool.core.util.ZipUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.mortals.framework.ap.GlobalSysInfo; import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -56,8 +57,7 @@ import org.springframework.util.ObjectUtils; ...@@ -56,8 +57,7 @@ import org.springframework.util.ObjectUtils;
import java.util.*; 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.*;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_URL;
/** /**
* SiteService * SiteService
...@@ -115,7 +115,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -115,7 +115,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
refresh = true; refresh = true;
} }
if(!oldSite.getEnglishName().equals(entity.getEnglishName())){ if (!oldSite.getEnglishName().equals(entity.getEnglishName())) {
refresh = true; refresh = true;
} }
...@@ -350,6 +350,14 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -350,6 +350,14 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Override @Override
public List<SiteTreeSelect> getSiteTree(Context context) { public List<SiteTreeSelect> getSiteTree(Context context) {
List<SiteTreeSelect> siteTreeSelects = siteTreeMap.get(context.getUser().getId()); List<SiteTreeSelect> siteTreeSelects = siteTreeMap.get(context.getUser().getId());
String siteTreeSelectStr = cacheService.hget(USER_SITE_TREE, context.getUser().getId().toString(), String.class);
//反序列化树对象
JSONArray jsonArray = JSON.parseArray(siteTreeSelectStr);
List<SiteTreeSelect> collect = jsonArray.stream().map(item -> {
SiteTreeSelect siteTreeSelect = JSON.parseObject(item.toString(), SiteTreeSelect.class);
return siteTreeSelect;
}).collect(Collectors.toList());
log.info("siteTree:{}",JSON.toJSONString(collect));
//如果所属站点为空返回全节点树 //如果所属站点为空返回全节点树
if (!ObjectUtils.isEmpty(siteTreeSelects)) { if (!ObjectUtils.isEmpty(siteTreeSelects)) {
return siteTreeSelects; return siteTreeSelects;
...@@ -464,11 +472,15 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -464,11 +472,15 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Override @Override
public void setSiteTree(List<SiteTreeSelect> list, Context context) { public void setSiteTree(List<SiteTreeSelect> list, Context context) {
siteTreeMap.put(context.getUser().getId(), list); siteTreeMap.put(context.getUser().getId(), list);
//存放到redis中去
cacheService.hsetnx(USER_SITE_TREE, context.getUser().getId().toString(), JSON.toJSONString(list));
} }
@Override @Override
public void removeSiteTree(List<SiteTreeSelect> list, Context context) { public void removeSiteTree(List<SiteTreeSelect> list, Context context) {
siteTreeMap.remove(context.getUser().getId()); siteTreeMap.remove(context.getUser().getId());
cacheService.hdel(USER_SITE_TREE, context.getUser().getId().toString());
} }
@Override @Override
......
...@@ -128,7 +128,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -128,7 +128,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
try { try {
Context context = new Context(); Context context = new Context();
UserEntity userEntity = new UserEntity(); UserEntity userEntity = new UserEntity();
userEntity.setId(1L); userEntity.setId(0L);
context.setUser(userEntity); context.setUser(userEntity);
List<SiteTreeSelect> siteTree = this.service.getSiteTree(context); List<SiteTreeSelect> siteTree = this.service.getSiteTree(context);
model.put("siteTree", siteTree); model.put("siteTree", siteTree);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<fileNamePattern>${logFilePath}/${springApplicationName:-default}/${springApplicationName:-default}-info.log.%d{yyyyMMdd}</fileNamePattern> <fileNamePattern>${logFilePath}/${springApplicationName:-default}/${springApplicationName:-default}-info.log.%d{yyyyMMdd}</fileNamePattern>
<cleanHistoryOnStart>true</cleanHistoryOnStart> <cleanHistoryOnStart>true</cleanHistoryOnStart>
<!--日志文件保留天数--> <!--日志文件保留天数-->
<MaxHistory>7</MaxHistory> <MaxHistory>15</MaxHistory>
</rollingPolicy> </rollingPolicy>
</appender> </appender>
<!-- 异常文件输出策略--> <!-- 异常文件输出策略-->
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logFilePath}/${springApplicationName:-default}/${springApplicationName:-default}-error.log.%d{yyyyMMdd}</fileNamePattern> <fileNamePattern>${logFilePath}/${springApplicationName:-default}/${springApplicationName:-default}-error.log.%d{yyyyMMdd}</fileNamePattern>
<!--日志文件保留天数--> <!--日志文件保留天数-->
<MaxHistory>7</MaxHistory> <MaxHistory>15</MaxHistory>
</rollingPolicy> </rollingPolicy>
</appender> </appender>
...@@ -69,8 +69,8 @@ ...@@ -69,8 +69,8 @@
<appender-ref ref="fileError"/> <appender-ref ref="fileError"/>
</logger> </logger>
<logger name="com.mortals.xhx.module"> <!-- <logger name="com.mortals.xhx.module">
<level value="debug"/> <level value="debug"/>
</logger> </logger>-->
</configuration> </configuration>
\ No newline at end of file
...@@ -45,7 +45,7 @@ POST {{baseUrl}}/dept/getBusinessByDept ...@@ -45,7 +45,7 @@ POST {{baseUrl}}/dept/getBusinessByDept
Content-Type: application/json Content-Type: application/json
{ {
"idList":[450] "idList":[450,451]
} }
###部门查看 ###部门查看
......
...@@ -17,5 +17,9 @@ ...@@ -17,5 +17,9 @@
"base-yibin": { "base-yibin": {
"baseUrl": "http://10.12.185.213:11078/base" "baseUrl": "http://10.12.185.213:11078/base"
},
"base-yibin-web": {
"baseUrl": "http://112.19.80.237:11078/base"
} }
} }
\ No newline at end of file
...@@ -23,8 +23,9 @@ ...@@ -23,8 +23,9 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 文件保存策略--> <!-- 文件保存策略-->
<fileNamePattern>${logFilePath}/${springApplicationName:-default}/${springApplicationName:-default}-info.log.%d{yyyyMMdd}</fileNamePattern> <fileNamePattern>${logFilePath}/${springApplicationName:-default}/${springApplicationName:-default}-info.log.%d{yyyyMMdd}</fileNamePattern>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
<!--日志文件保留天数--> <!--日志文件保留天数-->
<MaxHistory>7</MaxHistory> <MaxHistory>15</MaxHistory>
</rollingPolicy> </rollingPolicy>
</appender> </appender>
<!-- 异常文件输出策略--> <!-- 异常文件输出策略-->
......
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
}, },
"portal-yibin": { "portal-yibin": {
"baseUrl": "http://10.12.185.213:11078/zwfw" "baseUrl": "http://10.12.185.213:11078/zwfw"
},
"portal-yibin-web": {
"baseUrl": "http://112.19.80.237:11078/zwfw"
} }
} }
\ No newline at end of file
...@@ -23,8 +23,9 @@ ...@@ -23,8 +23,9 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 文件保存策略--> <!-- 文件保存策略-->
<fileNamePattern>${logFilePath}/${springApplicationName:-default}/${serspringApplicationNameverPort:-default}-info.log.%d{yyyyMMdd}</fileNamePattern> <fileNamePattern>${logFilePath}/${springApplicationName:-default}/${serspringApplicationNameverPort:-default}-info.log.%d{yyyyMMdd}</fileNamePattern>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
<!--日志文件保留天数--> <!--日志文件保留天数-->
<MaxHistory>7</MaxHistory> <MaxHistory>15</MaxHistory>
</rollingPolicy> </rollingPolicy>
</appender> </appender>
<!-- 异常文件输出策略--> <!-- 异常文件输出策略-->
......
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