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

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

parent b2a9449a
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.Configuration;
import org.springframework.web.cors.CorsConfiguration;
......@@ -18,6 +20,8 @@ public class CorsConfig implements WebMvcConfigurer {
@Bean
public CorsFilter corsFilter(){
ParserConfig.getGlobalInstance().putDeserializer(SiteTreeSelect.class, new SiteTreeSelect.Deserializer());
//初始化配置对象
CorsConfiguration configuration = new CorsConfiguration();
//允许跨域访问的域名
......
......@@ -137,4 +137,8 @@ public final class Constant {
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 {
SyncTreeSiteThread syncTreeSiteThread = new SyncTreeSiteThread(contextTemp);
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->{
Context context = new Context();
......
......@@ -30,26 +30,25 @@ import java.util.List;
@Service("SyncUserTask")
public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
private ResourceService resourceService;
@Autowired
private UserService userService;
@Autowired
private IUserFeign userFeign;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("同步用户");
UserPdu userPdu = new UserPdu();
userPdu.setPage(1);
userPdu.setSize(-1);
Rest<RespData<List<UserPdu>>> list = userFeign.list(userPdu);
userService.updateUserList(list.getData().getData());
//resourceService.updateUserList();
/* UserPdu userPdu = new UserPdu();
......
......@@ -111,7 +111,6 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa
List<Long> businessIdList = Arrays.asList(businessIds.split(",")).stream().map(Long::parseLong).collect(Collectors.toList());
//先删除后再新增
SiteBusinessQuery siteBusinessQuery = new SiteBusinessQuery();
siteBusinessQuery.setSiteId(siteId);
siteBusinessQuery.setBusinessIdList(businessIdList);
......@@ -136,7 +135,6 @@ public class BusinessServiceImpl extends AbstractCRUDCacheServiceImpl<BusinessDa
}
private void updateOrSave(BusinessEntity item, Long siteId, Context context) {
SiteBusinessEntity siteBusinessEntity = new SiteBusinessEntity();
BeanUtils.copyProperties(item, siteBusinessEntity, BeanUtil.getNullPropertyNames(item));
SiteEntity siteEntity = siteService.get(siteId);
......
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 lombok.Data;
import org.springframework.util.ObjectUtils;
import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -67,6 +74,9 @@ public class SiteTreeSelect implements Serializable {
*/
private List<SiteTreeSelect> children;
public SiteTreeSelect() {
}
public SiteTreeSelect(AreaEntity entity) {
//如果是站点,则替换名称和id
......@@ -113,16 +123,35 @@ public class SiteTreeSelect implements Serializable {
}
public SiteTreeSelect(SiteEntity entity) {
this.id = entity.getId().toString();
this.label = entity.getSiteName();
this.isLeaf = true;
this.type = "site";
this.icon = "el-icon-document";
this.longitude = entity.getLongitude();
this.latitude = entity.getLatitude();
// 反序列化器
public static class Deserializer implements ObjectDeserializer {
@Override
public SiteTreeSelect deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
SiteTreeSelect node = new SiteTreeSelect();
JSONObject jsonObject = parser.parseObject();
node.setId(jsonObject.getString("id"));
node.setSiteCode(jsonObject.getString("siteCode"));
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;
import cn.hutool.core.util.URLUtil;
import cn.hutool.core.util.ZipUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
......@@ -56,8 +57,7 @@ import org.springframework.util.ObjectUtils;
import java.util.*;
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_URL;
import static com.mortals.xhx.common.key.Constant.*;
/**
* SiteService
......@@ -115,7 +115,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
refresh = true;
}
if(!oldSite.getEnglishName().equals(entity.getEnglishName())){
if (!oldSite.getEnglishName().equals(entity.getEnglishName())) {
refresh = true;
}
......@@ -350,6 +350,14 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Override
public List<SiteTreeSelect> getSiteTree(Context context) {
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)) {
return siteTreeSelects;
......@@ -464,11 +472,15 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Override
public void setSiteTree(List<SiteTreeSelect> list, Context context) {
siteTreeMap.put(context.getUser().getId(), list);
//存放到redis中去
cacheService.hsetnx(USER_SITE_TREE, context.getUser().getId().toString(), JSON.toJSONString(list));
}
@Override
public void removeSiteTree(List<SiteTreeSelect> list, Context context) {
siteTreeMap.remove(context.getUser().getId());
cacheService.hdel(USER_SITE_TREE, context.getUser().getId().toString());
}
@Override
......@@ -556,11 +568,11 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
log.info("需要添加事项数量====" + subList.size());
//差集进行插入并更新详细数据
if (!ObjectUtils.isEmpty(subList)) {
for (MatterEntity matterEntity : subList) {
DeptEntity deptCache = deptService.getExtCache(matterEntity.getDeptCode());
matterEntity.setDeptName(deptCache == null ? "" : deptCache.getName());
matterService.save(matterEntity, context);
}
for (MatterEntity matterEntity : subList) {
DeptEntity deptCache = deptService.getExtCache(matterEntity.getDeptCode());
matterEntity.setDeptName(deptCache == null ? "" : deptCache.getName());
matterService.save(matterEntity, context);
}
List<List<MatterEntity>> partition = ListUtil.partition(subList, 100);
for (List<MatterEntity> matterEntityList : partition) {
......
......@@ -128,7 +128,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
try {
Context context = new Context();
UserEntity userEntity = new UserEntity();
userEntity.setId(1L);
userEntity.setId(0L);
context.setUser(userEntity);
List<SiteTreeSelect> siteTree = this.service.getSiteTree(context);
model.put("siteTree", siteTree);
......
......@@ -25,7 +25,7 @@
<fileNamePattern>${logFilePath}/${springApplicationName:-default}/${springApplicationName:-default}-info.log.%d{yyyyMMdd}</fileNamePattern>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
<!--日志文件保留天数-->
<MaxHistory>7</MaxHistory>
<MaxHistory>15</MaxHistory>
</rollingPolicy>
</appender>
<!-- 异常文件输出策略-->
......@@ -40,7 +40,7 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logFilePath}/${springApplicationName:-default}/${springApplicationName:-default}-error.log.%d{yyyyMMdd}</fileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>7</MaxHistory>
<MaxHistory>15</MaxHistory>
</rollingPolicy>
</appender>
......@@ -69,8 +69,8 @@
<appender-ref ref="fileError"/>
</logger>
<logger name="com.mortals.xhx.module">
<!-- <logger name="com.mortals.xhx.module">
<level value="debug"/>
</logger>
</logger>-->
</configuration>
\ No newline at end of file
......@@ -45,7 +45,7 @@ POST {{baseUrl}}/dept/getBusinessByDept
Content-Type: application/json
{
"idList":[450]
"idList":[450,451]
}
###部门查看
......
......@@ -17,5 +17,9 @@
"base-yibin": {
"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 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 文件保存策略-->
<fileNamePattern>${logFilePath}/${springApplicationName:-default}/${springApplicationName:-default}-info.log.%d{yyyyMMdd}</fileNamePattern>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
<!--日志文件保留天数-->
<MaxHistory>7</MaxHistory>
<MaxHistory>15</MaxHistory>
</rollingPolicy>
</appender>
<!-- 异常文件输出策略-->
......
......@@ -10,6 +10,10 @@
},
"portal-yibin": {
"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 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 文件保存策略-->
<fileNamePattern>${logFilePath}/${springApplicationName:-default}/${serspringApplicationNameverPort:-default}-info.log.%d{yyyyMMdd}</fileNamePattern>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
<!--日志文件保留天数-->
<MaxHistory>7</MaxHistory>
<MaxHistory>15</MaxHistory>
</rollingPolicy>
</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