Commit 0715e197 authored by 赵啸非's avatar 赵啸非

添加应用白名单接口

parent a484c38c
Pipeline #2477 failed with stages
package com.mortals.xhx.feign.site;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SiteMatterPdu;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 站点事项 Feign接口
* @author zxfei
* @date 2023-02-17
*/
@FeignClient(name = "", path = "", fallbackFactory = SiteMatterFeignFallbackFactory.class)
public interface ISiteMatterFeign extends IFeign {
/**
* 查看站点事项列表
*
* @param siteMatterPdu
* @return
*/
@PostMapping(value = "/site/matter/list")
Rest<RespData<List<SiteMatterPdu>>> list(@RequestBody SiteMatterPdu siteMatterPdu);
/**
* 查看站点事项
*
* @param id
* @return
*/
@GetMapping(value = "/site/matter/info")
Rest<SiteMatterPdu> info(@RequestParam(value = "id") Long id);
/**
* 删除站点事项
*
* @param ids
* @return
*/
@GetMapping(value = "/site/matter/delete")
Rest<Void> delete(Long[] ids,@RequestHeader("Authorization") String authorization);
/**
* 站点事项保存更新
*
* @param siteMatterPdu
* @return
*/
@PostMapping(value = "/site/matter/save")
Rest<RespData<SiteMatterPdu>> save(@RequestBody SiteMatterPdu siteMatterPdu,@RequestHeader("Authorization") String authorization);
}
@Slf4j
@Component
class SiteMatterFeignFallbackFactory implements FallbackFactory<ISiteMatterFeign> {
@Override
public ISiteMatterFeign create(Throwable t) {
return new ISiteMatterFeign() {
@Override
public Rest<RespData<List<SiteMatterPdu>>> list(SiteMatterPdu siteMatterPdu) {
return Rest.fail("暂时无法获取站点事项列表,请稍后再试!");
}
@Override
public Rest<SiteMatterPdu> info(Long id) {
return Rest.fail("暂时无法获取站点事项详细,请稍后再试!");
}
@Override
public Rest<Void> delete(Long[] ids, String authorization) {
return Rest.fail("暂时无法删除站点事项,请稍后再试!");
}
@Override
public Rest<RespData<SiteMatterPdu>> save(SiteMatterPdu siteMatterPdu, String authorization) {
return Rest.fail("暂时无法保存站点事项,请稍后再试!");
}
};
}
}
package com.mortals.xhx.daemon.task;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SiteMatterPdu;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.feign.site.ISiteMatterFeign;
import com.mortals.xhx.module.sheet.model.SheetMatterEntity;
import com.mortals.xhx.module.sheet.service.SheetMatterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.List;
import java.util.stream.Collectors;
/**
* 同步事项列表
*/
@Slf4j
@Service("SyncSiteMatterTask")
public class SyncSiteMatterTaskImpl implements ITaskExcuteService {
@Autowired
private ISiteFeign siteFeign;
@Autowired
private ISiteMatterFeign siteMatterFeign;
@Autowired
private SheetMatterService sheetMatterService;
@Override
public void excuteTask(ITask task) throws AppException {
SitePdu sitePdu = new SitePdu();
sitePdu.setId(1L);
Rest<List<SitePdu>> siteRest = siteFeign.getFlatSitesBySiteId(sitePdu);
if (siteRest.getCode() == YesNoEnum.YES.getValue()) {
siteRest.getData().forEach(site -> {
SiteMatterPdu siteMatterPdu = new SiteMatterPdu();
siteMatterPdu.setPage(1);
siteMatterPdu.setSize(-1);
Rest<RespData<List<SiteMatterPdu>>> siteMatterRest = siteMatterFeign.list(siteMatterPdu);
if (siteMatterRest.getCode() == YesNoEnum.YES.getValue()) {
//删除后新增
List<SheetMatterEntity> sheetMatterEntities = siteMatterRest.getData().getData().stream().map(siteMatter -> {
SheetMatterEntity sheetMatterEntity = new SheetMatterEntity();
sheetMatterEntity.initAttrValue();
sheetMatterEntity.setSiteId(siteMatter.getSiteId());
sheetMatterEntity.setMatterName(siteMatter.getMatterName());
sheetMatterEntity.setMatterNo(siteMatter.getMatterCode());
sheetMatterEntity.setDeptCode(siteMatter.getDeptCode());
sheetMatterEntity.setDeptName(siteMatter.getDeptCode());
return sheetMatterEntity;
}).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(sheetMatterEntities)) {
sheetMatterService.save(sheetMatterEntities);
}
}
});
}
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
......@@ -319,9 +319,10 @@ public class HomeController extends BaseJsonBodyController {
model.put("dayThrift", todaySum); //今日节约
long sum = matterDatumPrintOnlineEntities.stream().collect(Collectors.summarizingInt(x -> x.getPage())).getSum();
model.put("totalThrift", sum*2); //累计节约
model.put("totalThrift", sum * 2); //累计节约
Rest<com.mortals.xhx.common.pdu.site.SitePdu> info = siteFeign.info(homeQueryPdu.getSiteId());
model.put("title", info == null ? "" : info.getData().getSiteName()); //标题
model.put("title", info.getData() == null ? "" : info.getData().getSiteName()); //标题
BasesetEntity basesetEntity = basesetService.selectOne(new BasesetQuery().siteId(homeQueryPdu.getSiteId()));
......@@ -344,6 +345,7 @@ public class HomeController extends BaseJsonBodyController {
/**
* 自助服务应用
*
* @return
*/
@GetMapping({"app/list"})
......@@ -352,13 +354,13 @@ public class HomeController extends BaseJsonBodyController {
String appWhiteStr = GlobalSysInfo.getParamValue(Constant.PARAMS_WHITE_APP_LIST, "中心简介,办事指南,意见建议,中心简介");
Set<String> appWhiteSet = StrUtil.split(appWhiteStr, ",").stream().collect(Collectors.toSet());
Rest<List<AppPdu>> ret = new Rest();
List<AppPdu> collect =new ArrayList<>();
List<AppPdu> collect = new ArrayList<>();
int code = VALUE_RESULT_SUCCESS;
try {
AppPdu appPdu = new AppPdu();
appPdu.setSiteId(siteId);
Rest<RespData<List<AppPdu>>> appRest = appFeign.list(appPdu);
if(appRest.getCode()==YesNoEnum.YES.getValue()){
if (appRest.getCode() == YesNoEnum.YES.getValue()) {
collect = appRest.getData().getData().stream().filter(f -> appWhiteSet.contains(f.getAppName())).collect(Collectors.toList());
}
} catch (Exception e) {
......
......@@ -21,7 +21,7 @@
and a.matterName like #{condition.matterName}
</if>
<if test="condition.matterFullName != null and condition.matterFullName != ''">
and a.matterFullName like #{condition.matterFullName}
and a.matterName like #{condition.matterName}
</if>
</trim>
</trim>
......@@ -47,7 +47,7 @@
and a.matterName like #{condition.matterName}
</if>
<if test="condition.matterFullName != null and condition.matterFullName != ''">
and a.matterFullName like #{condition.matterFullName}
and a.matterName like #{condition.matterName}
</if>
</trim>
</trim>
......
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