* 'master' of http://221.0.232.152:9393/ability-center/share-platform:
  ...
  fix bug
  selectDTOById 查出多条数据
  申购车不需要出attr
  ...
  一些优化
  ...
  ...
  屮...
  查询能力列表去除infoList 统一门户及其他页面查询能力条件 新增知识库对接 ...

# Conflicts:
#	renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Filter.java
#	renren-admin/src/main/resources/application.yml
This commit is contained in:
huangweixiong 2022-06-03 14:41:12 +08:00
commit 95e59c82f4
26 changed files with 503 additions and 235 deletions

View File

@ -1,12 +1,10 @@
package io.renren;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@ -27,7 +25,6 @@ public class AdminApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(AdminApplication.class, args);
System.out.println("项目启动成功");
}
@Override

View File

@ -14,6 +14,7 @@ import io.renren.modules.activiti.service.ActRunningService;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.dto.TAbilityBatchApplicationDTO;
import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.security.user.SecurityUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.codehaus.jackson.map.ObjectMapper;
@ -68,6 +69,9 @@ public class AbilityCenterController {
return new Result().error("联系管理员添加流程");
}
return new Result().ok(abilityBatchApplicationDTO.getSystem().stream().map(index -> {
if (tAbilityApplicationService.countUserResourceApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId"))) > 0) { // 防止重复发起申请
return null;
}
TAbilityApplicationDTO tAbilityApplicationDTO = new TAbilityApplicationDTO();
tAbilityApplicationDTO.setArea(abilityBatchApplicationDTO.getArea());
tAbilityApplicationDTO.setAttachment(abilityBatchApplicationDTO.getAttachment());

View File

@ -86,7 +86,6 @@ public class CensusController {
};
dbAmount.add(nullMap);
}
});
Long sum = dbAmount.stream().mapToLong(index -> Long.valueOf(index.get("amount").toString())).sum();
Map<String, Object> sumMap = new HashMap<String, Object>() {

View File

@ -25,7 +25,7 @@ public class FordController {
String uri = request.getRequestURI();
String fordUrl = imageDomain + uri;
URLConnection con = null;
URLConnection con;
try {
URL url = new URL(fordUrl);

View File

@ -34,4 +34,13 @@ public interface TAbilityApplicationDao extends BaseDao<TAbilityApplicationEntit
List<Map> selectDeptApplyCount(Integer n);
List<String> selectDeptApply(Long deptId);
/**
* 统计该用户对某个资源的申请数量
*
* @param userId
* @param resourceId
* @return
*/
Long countUserResourceApply(Long userId, Long resourceId);
}

View File

@ -34,4 +34,13 @@ public interface TAbilityApplicationService extends CrudService<TAbilityApplicat
List<Map> selectDeptApplyCount(Integer n);
List<String> selectDeptApply(Long deptId);
/**
* 统计该用户对某个资源的申请数量
*
* @param userId
* @param resourceId
* @return
*/
Long countUserResourceApply(Long userId, Long resourceId);
}

View File

@ -73,5 +73,17 @@ public class TAbilityApplicationServiceImpl extends CrudServiceImpl<TAbilityAppl
return baseDao.selectDeptApply(deptId);
}
/**
* 统计该用户对某个资源的申请数量
*
* @param userId
* @param resourceId
* @return
*/
@Override
public Long countUserResourceApply(Long userId, Long resourceId) {
return null;
}
}

View File

@ -1,5 +1,7 @@
package io.renren.modules.resource.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.renren.common.annotation.LogOperation;
import io.renren.common.constant.Constant;
@ -9,6 +11,7 @@ import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.service.ResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@ -17,11 +20,16 @@ import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import springfox.documentation.annotations.ApiIgnore;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -36,6 +44,36 @@ import java.util.Map;
@Api(tags = "资源表")
public class ResourceController {
@Value("${qdyjj.ipAndPort}")
private String ipAndPort;
@Value("${zsk.appid}")
private String appId;
@Value("${zsk.appkey}")
private String appKey;
@Value("${zsk.url.sign}")
private String sign;
@Value("${zsk.url.gateway}")
private String gateway;
@Value("${zsk.methodId}")
private String methodId;
@Value("${zsk.param.charset}")
private String charset;
@Value("${zsk.param.origin}")
private String origin;
@Value("${zsk.param.version}")
private String version;
@Value("${zsk.catalogIds}")
private String[] catalogIds;
@Autowired
private ResourceService resourceService;
@ -183,7 +221,6 @@ public class ResourceController {
" <soap:Body>\n" +
" </soap:Body>\n" +
"</soap:Envelope>";
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.set("SOAPAction", "http://tempuri.org/ZywMessagePort");
requestHeaders.setContentType(MediaType.TEXT_XML);
@ -195,11 +232,119 @@ public class ResourceController {
return new Result().ok(map);
} catch (Exception e) {
e.printStackTrace();
return new Result().error();
return new Result().ok(new HashMap<>());
}
}
@GetMapping("qdyjjWeather")
@ApiOperation("青岛应急局-查询青岛市地区天气信息")
public Result qdyjjWeather(String cityName){
String loginUrl = "http://" + ipAndPort + "/service-oauth/login";
String weatherUrl = "http://" + ipAndPort + "/service-map/qxWeather/getTodayWeatherInfo";
HashMap<String, Object> loginParam = new HashMap<>();
loginParam.put("loginName", "qdyjj");
loginParam.put("loginPassword", "i/NA1EJ70VaPP0mhFGyJsg==");
HttpEntity<String> loginRequestEntity = new HttpEntity(loginParam, new HttpHeaders());
try {
String loginBody = restTemplate.postForObject(loginUrl, loginRequestEntity, String.class);
JSONObject json = JSON.parseObject(loginBody);
String token = json.getString("data");
MultiValueMap<String, Object> weatherParam = new LinkedMultiValueMap<>();
weatherParam.add("cityName", cityName);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add("token", token);
HttpEntity<String> weatherRequestEntity = new HttpEntity(weatherParam, httpHeaders);
String weatherBody = restTemplate.postForEntity(weatherUrl, weatherRequestEntity, String.class).getBody();
return new Result().ok(weatherBody);
} catch (Exception e) {
e.printStackTrace();
return new Result().ok(new HashMap(){{
put("message", "接口调用失败!");
put("code", "500");
}});
}
}
@GetMapping("knowledgeBase")
@ApiOperation("对接知识库数据")
public void knowledgeBase(){
long timestamp = new Date().getTime();
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
paramMap.add("app_id",appId);
paramMap.add("interface_id", methodId);
paramMap.add("version", version);
paramMap.add("charset", charset);
paramMap.add("timestamp", String.valueOf(timestamp));
paramMap.add("origin", origin);
String bizContent;
for (String catalogId: catalogIds) {
bizContent = "{\"appkey\":\""+ appKey +"\",\n" +
"\"catalogId\":\""+ catalogId +"\",\n" +
"\"pageIndex\":1,\n" +
"\"pageSize\":1000}";
paramMap.add("biz_content", bizContent);
try {
String signResult = restTemplate.postForObject(sign, paramMap, String.class);
JSONObject signJsonObject = JSON.parseObject(signResult);
Map<String, Object> signData = (Map<String, Object>)signJsonObject.get("data");
String signString = signData.get("sign").toString();
paramMap.add("sign", signString);
String gatewayResult = restTemplate.postForObject(gateway, paramMap, String.class);
JSONObject gatewayJsonObject = JSON.parseObject(gatewayResult);
JSONObject gatewayData = JSON.parseObject(gatewayJsonObject.get("data").toString());
JSONArray infos = gatewayData.getJSONObject("data").getJSONArray("infos");
infos.forEach(item -> {
Map<String, Object> map = (Map<String, Object>) item;
ResourceDTO dto = new ResourceDTO();
dto.setName(map.get("title").toString());
dto.setType("知识库");
dto.setVisits(0L);
//所属部门暂时设为青岛市政府办公厅
dto.setDeptId(1517116100113850370L);
dto.setDelFlag(0);
ArrayList<AttrEntity> infoList = new ArrayList<>();
map.forEach((key, value) -> {
switch (key) {
case "title":
dto.setName(value.toString());
break;
case "url":
dto.setLink(value.toString());
break;
case "createtime":
Date createDate = new Date(Long.parseLong(value.toString()));
dto.setCreateDate(createDate);
break;
default:
AttrEntity attrEntity = new AttrEntity();
attrEntity.setDelFlag(0);
attrEntity.setAttrType(key);
attrEntity.setAttrValue(value.toString());
infoList.add(attrEntity);
break;
}
});
AttrEntity attrEntity = new AttrEntity();
attrEntity.setDelFlag(0);
attrEntity.setAttrType("文件类型");
if ("f49561afc7204f008c4bb3cd821eb6ba".equals(catalogId)) {
attrEntity.setAttrValue("政府公报");
} else {
attrEntity.setAttrValue("政策解读");
}
infoList.add(attrEntity);
dto.setInfoList(infoList);
resourceService.insertWithAttrs(dto);
});
} catch (Exception e) {
e.printStackTrace();
}
paramMap.remove("sign");
paramMap.remove("biz_content");
}
}
@GetMapping("algorithmPage")
@ApiOperation("算法仓分页查询")
@LogOperation("算法仓分页查询")
@ -225,4 +370,5 @@ public class ResourceController {
ExcelUtils.exportExcelToTarget(response, null, "资源表", list, ResourceExcel.class);
}
*/
}

View File

@ -23,9 +23,12 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
List<ResourceDTO> selectWithAttrs(@Param("dto") ResourceDTO resourceDTO,
@Param("orderField") String orderField,
@Param("orderType") String orderType);
@Param("orderType") String orderType,
@Param("pageNum") Integer pageNum,
@Param("pageSize") Integer pageSize
);
List<Map> selectTypeCount(Long deptId);
List<Map> selectTypeCount();
List<ResourceDTO> selectMostPopular(Map<String, Object> selectMap);

View File

@ -115,7 +115,6 @@ public class ResourceEntity extends BaseEntity {
*/
private String note5;
/**
* 附件
*/
@ -124,11 +123,11 @@ public class ResourceEntity extends BaseEntity {
/**
* 下架理由
*/
// private String undercarriageReason;
private String undercarriageReason;
/**
* 提起下架人员
*/
// private String undercarriageUserName;
private String undercarriageUserName;
}

View File

@ -23,17 +23,13 @@ import io.renren.modules.resourceCar.dao.ResourceCarDao;
import io.renren.modules.resourceCollection.dao.ResourceCollectionDao;
import io.renren.modules.resourceScore.dao.ResourceScoreDao;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.security.user.UserDetail;
import io.renren.modules.sys.dao.SysDeptDao;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -107,9 +103,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resourceEntity.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
}
resourceDao.insert(resourceEntity);
BeanUtils.copyProperties(resourceEntity, dto);
List<AttrEntity> attrEntities = dto.getInfoList();
if (attrEntities != null) {
attrEntities.forEach(item -> {
@ -177,13 +171,13 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
Page<ResourceDTO> resultPage = new Page<>(pageNum, pageSize);
if (resourceDTO.getInfoList().isEmpty()) {
List<ResourceDTO> resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType);
resourceDTOS.forEach(item -> {
item.setInfoList(this.selectAttrsByResourceId(item.getId()));
});
//resourceDTOS.forEach(item -> {
// item.setInfoList(this.selectAttrsByResourceId(item.getId()));
//});
resultPage.setRecords(resourceDTOS);
resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 0, 100000, orderField, orderType).size());
} else {
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType);
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType, (pageNum - 1) * pageSize, pageSize);
int j = Math.min(pageNum * pageSize, resourceDTOS.size());
if (resourceDTOS.isEmpty()) {
resultPage.setRecords(null);
@ -211,12 +205,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public Object selectTotal() {
UserDetail user = SecurityUser.getUser();
HashMap<String, Object> resultMap = new HashMap<>();
List<Map> totalMap = resourceDao.selectTypeCount(null);
resultMap.put("total", totalMap);
List<Map> deptMap = resourceDao.selectTypeCount(user.getDeptId());
resultMap.put("dept", deptMap);
resultMap.put("total", resourceDao.selectTypeCount());
return resultMap;
}
@ -225,11 +215,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
public Object selectNewest(JSONObject jsonObject) {
IPage<ResourceEntity> page = new Page<>(jsonObject.getIntValue("pageNum"), jsonObject.getIntValue("pageSize"));
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("create_date")
.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type"))
.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag());
IPage<ResourceEntity> entityIPage = resourceDao.selectPage(page, queryWrapper);
return entityIPage;
queryWrapper.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type"))
.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag())
.orderByDesc("create_date");
return resourceDao.selectPage(page, queryWrapper);
}
@ -326,11 +315,14 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
HashMap<String, Object> resourceMap = new HashMap<>();
resourceMap.put("type", "全部能力目录");
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.in(true, "del_flag", 0, 5)
queryWrapper.eq("del_flag", 0)
.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type"));
resourceMap.put("total", resourceDao.selectCount(queryWrapper));
resultList.add(resourceMap);
List<Map<String, Object>> typeMapList = resourceDao.selectGroupByDeptId(jsonObject.getString("type"));
if (typeMapList.isEmpty()) {
return resultList;
}
Map<String, List<Map<String, Object>>> listMap = typeMapList.stream()
.collect(Collectors.groupingBy(m -> m.get("type").toString()));
//区级要根据行政区划多加一层结构
@ -344,14 +336,14 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
map.put("dataList", item.getValue());
resultList.add(map);
});
List<Map<String, Object>> areaList = listMap.get("区级");
Map<String, List<Map<String, Object>>> areaTypeList = areaList.stream()
.collect(Collectors.groupingBy(m -> m.get("districtName").toString()));
Optional<List<Map<String, Object>>> areaList = Optional.ofNullable(listMap.get("区级"));
Optional<Map<String, List<Map<String, Object>>>> areaTypeList = Optional.ofNullable(areaList.orElse(new ArrayList<>()).stream()
.collect(Collectors.groupingBy(m -> m.get("districtName").toString())));
HashMap<Object, Object> areaMap = new HashMap<>();
areaMap.put("type", "区级");
areaMap.put("total", resourceDao.selectTypeCountByDept("区级", jsonObject.getString("type")));
ArrayList<Map> areaListTemp = new ArrayList<>();
areaTypeList.entrySet().stream().forEach(item -> {
areaTypeList.orElse(new HashMap<>()).entrySet().stream().forEach(item -> {
HashMap<String, Object> map = new HashMap<>();
map.put("type", item.getKey());
map.put("total", resourceDao.selectTypeCountByDist(item.getKey(), jsonObject.getString("type")));
@ -428,7 +420,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public List<String> selectDeptProvide(Long deptId) {
return baseDao.selectDeptProvide(deptId);
}

View File

@ -2,7 +2,6 @@ package io.renren.modules.resourceCar.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.resource.service.ResourceService;
@ -67,13 +66,13 @@ public class ResourceCarServiceImpl extends CrudServiceImpl<ResourceCarDao, Reso
}else {
ResourceCarEntity entity = carEntities.get(0);
ResourceCarEntity carEntity = new ResourceCarEntity();
BeanUtils.copyProperties(entity, carEntity, "updateDate");
BeanUtils.copyProperties(entity, carEntity, "updateDate", "updater");
resourceCarDao.updateById(carEntity);
}
}
@Override
public IPage<ResourceCarDTO> selectPage(Map<String, Object> params) {
public Page<ResourceCarDTO> selectPage(Map<String, Object> params) {
UserDetail user = SecurityUser.getUser();
int pageNum = Integer.parseInt(params.get("pageNum").toString());
int pageSize = Integer.parseInt(params.get("pageSize").toString());
@ -81,7 +80,8 @@ public class ResourceCarServiceImpl extends CrudServiceImpl<ResourceCarDao, Reso
params.put("userId", user.getId());
List<ResourceCarDTO> resourceCarDTOS = resourceCarDao.selectPageWithResource(params, (pageNum - 1) * pageSize, pageSize);
resourceCarDTOS.forEach(item -> {
item.setResourceDTO(resourceService.selectWithAttrs(item.getResourceId()));
//TODO:不需带attr属性数据
item.setResourceDTO(resourceService.get(item.getResourceId()));
});
List<ResourceCarDTO> resourceCarDTOSs = resourceCarDao.selectPageWithResource(params, 0, 100000);
page.setRecords(resourceCarDTOS);

View File

@ -40,7 +40,7 @@ public class SysDeptDTO extends TreeNode implements Serializable {
@ApiModelProperty(value = "类型1省级部门2市级部门3区级部门4企业")
private Integer type;
@ApiModelProperty(value = "")
@ApiModelProperty(value = "地区")
private Long district;
@ApiModelProperty(value = "排序")

View File

@ -8,13 +8,13 @@ import io.renren.modules.taskList.service.ShangTangService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Map;
import java.util.Optional;
@RestController
@RequestMapping("STapi/project")
@ -29,74 +29,106 @@ public class ShangTangController {
private TaskListControllerDao taskListControllerDao;
/**
* 事件模板分页查询接口
*
* @return
*/
@RequestMapping("tamplate")
@ApiOperation("事件模板分页查询接口")
public JSONObject tamplate(){
public JSONObject tamplate() {
return shangTangService.template();
}
/**
* 定时插入场景任务列表
*
*/
@RequestMapping("insertTaskList")
@ApiOperation("场景任务列表插入")
@Scheduled(cron = "0 */1 * * * ?")
//@Scheduled(cron = "0 */1 * * * ?")
@Transactional
public void insertTaskList(){
public void insertTaskList() {
log.info("insertTaskList!");
taskListControllerDao.deleteAll();
JSONObject jobj = this.tamplate();
JSONObject datajobj = jobj.getJSONObject("data");
JSONArray tamplateList = datajobj.getJSONArray("dataList");
//JSONArray tamplateList = jobj.getJSONArray("data");//构建JSONArray数组
for (int i = 0 ; i < tamplateList.size();i++) {
Map<String, Object> key = (Map<String, Object>) tamplateList.get(i);
Optional<JSONObject> jobj = Optional.ofNullable(this.tamplate());
Optional<JSONObject> datajobj = Optional.ofNullable(jobj.orElse(new JSONObject()).getJSONObject("data"));
Optional<JSONArray> tamplateList = Optional.ofNullable(datajobj.orElse(new JSONObject()).getJSONArray("dataList"));
tamplateList.orElse(new JSONArray()).parallelStream().forEach(index -> {
Map<String, Object> key = (Map<String, Object>) index;
String eventType = (String) key.get("eventType");
String eventCnName = (String)key.get("eventCnName");
JSONObject taskListBody = shangTangService.tasklist(eventType);
if (taskListBody.size()>0){
JSONObject taskdatajobj = taskListBody.getJSONObject("data");
if (taskdatajobj!=null){
JSONArray taskdatajobjJSONArray = taskdatajobj.getJSONArray("dataList");
if (taskdatajobjJSONArray!=null){
for (int j = 0 ; j < taskdatajobjJSONArray.size();j++) {
Map<String, Object> key1 = (Map<String, Object>)taskdatajobjJSONArray.get(j);
String taskSerial = (String) key1.get("taskSerial");
Integer taskStatus = (Integer) key1.get("taskStatus");
JSONObject taskDetailObj = shangTangService.tasklistDetail(taskSerial);
JSONObject taskDetail = taskDetailObj.getJSONObject("data");
TaskListControllerEntity taskListobj = new TaskListControllerEntity();
if (taskDetail!=null){
String taskName = taskDetail.getString("taskName");
taskListobj .setTaskName(taskName);
}else{
taskListobj .setTaskName("任务停止");
}
taskListobj .setTaskSerial(taskSerial);
taskListobj.setTaskStatus(taskStatus);
taskListobj .setEventType(eventType);
taskListobj .setEventCnName(eventCnName);
taskListControllerDao.insert(taskListobj);
}
}
}
String eventCnName = (String) key.get("eventCnName");
JSONObject taskListBody = shangTangService.tasklist(eventType);
if (taskListBody.isEmpty()) {
return;
}
}
Optional<JSONObject> taskdatajobj = Optional.ofNullable(taskListBody.getJSONObject("data"));
taskdatajobj.ifPresent(task -> {
Optional<JSONArray> taskdatajobjJSONArray = Optional.ofNullable(task.getJSONArray("dataList"));
taskdatajobjJSONArray.orElse(new JSONArray()).stream().forEach(index_ -> {
Map<String, Object> key1 = (Map<String, Object>) index_;
String taskSerial = (String) key1.get("taskSerial");
Integer taskStatus = (Integer) key1.get("taskStatus");
Optional<JSONObject> taskDetailObj = Optional.ofNullable(shangTangService.tasklistDetail(taskSerial));
JSONObject taskDetail = taskDetailObj.orElse(new JSONObject()).getJSONObject("data");
TaskListControllerEntity taskListobj = new TaskListControllerEntity();
if (taskDetail != null) {
String taskName = taskDetail.getString("taskName");
taskListobj.setTaskName(taskName);
} else {
taskListobj.setTaskName("任务停止");
}
taskListobj.setTaskSerial(taskSerial);
taskListobj.setTaskStatus(taskStatus);
taskListobj.setEventType(eventType);
taskListobj.setEventCnName(eventCnName);
taskListControllerDao.insert(taskListobj);
});
});
});
// for (int i = 0; i < tamplateList.orElse(new JSONArray()).size(); i++) {
// Map<String, Object> key = (Map<String, Object>) tamplateList.get().get(i);
// String eventType = (String) key.get("eventType");
// String eventCnName = (String) key.get("eventCnName");
// JSONObject taskListBody = shangTangService.tasklist(eventType);
// if (taskListBody.size() > 0) {
// JSONObject taskdatajobj = taskListBody.getJSONObject("data");
// if (taskdatajobj != null) {
// JSONArray taskdatajobjJSONArray = taskdatajobj.getJSONArray("dataList");
// if (taskdatajobjJSONArray != null) {
// for (int j = 0; j < taskdatajobjJSONArray.size(); j++) {
// Map<String, Object> key1 = (Map<String, Object>) taskdatajobjJSONArray.get(j);
//
// String taskSerial = (String) key1.get("taskSerial");
// Integer taskStatus = (Integer) key1.get("taskStatus");
//
// JSONObject taskDetailObj = shangTangService.tasklistDetail(taskSerial);
// JSONObject taskDetail = taskDetailObj.getJSONObject("data");
//
// TaskListControllerEntity taskListobj = new TaskListControllerEntity();
//
// if (taskDetail != null) {
// String taskName = taskDetail.getString("taskName");
// taskListobj.setTaskName(taskName);
// } else {
// taskListobj.setTaskName("任务停止");
// }
//
// taskListobj.setTaskSerial(taskSerial);
// taskListobj.setTaskStatus(taskStatus);
//
// taskListobj.setEventType(eventType);
// taskListobj.setEventCnName(eventCnName);
// taskListControllerDao.insert(taskListobj);
// }
// }
// }
// }
// }
}
}

View File

@ -36,14 +36,14 @@ import java.util.Map;
/**
* test
*
* @author Mark sunlightcs@gmail.com
* @since 3.0 2022-05-24
*/
* test
*
* @author Mark sunlightcs@gmail.com
* @since 3.0 2022-05-24
*/
@RestController
@RequestMapping("/taskList/tasklistcontroller")
@Api(tags="任务列表查询")
@Api(tags = "任务列表查询")
public class TaskListController {
@Autowired
private TaskListControllerService taskListControllerService;
@ -54,13 +54,13 @@ public class TaskListController {
@GetMapping("page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String")
})
@RequiresPermissions("taskList:tasklistcontroller:page")
public Result<PageData<TaskListControllerDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
// @RequiresPermissions("taskList:tasklistcontroller:page")
public Result<PageData<TaskListControllerDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
PageData<TaskListControllerDTO> page = taskListControllerService.page(params);
return new Result<PageData<TaskListControllerDTO>>().ok(page);
@ -70,42 +70,42 @@ public class TaskListController {
@GetMapping("/selectTaskList")
@ApiOperation("根据分页以及任务名称状态查询数据")
// @RequiresPermissions("taskList:tasklistcontroller:info")
public Map<String,Object> get(
@RequestParam(value = "taskName",required = false) String taskName,
@RequestParam(value = "taskStatus",required = false) Integer taskStatus,
@RequestParam(value = "page",required = true,defaultValue = "1") Integer page,
@RequestParam(value = "pageSize",required = true,defaultValue = "10") Integer pageSize
){
public Map<String, Object> get(
@RequestParam(value = "taskName", required = false) String taskName,
@RequestParam(value = "taskStatus", required = false) Integer taskStatus,
@RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
@RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize
) {
Page<TaskListControllerEntity> page1 = new Page<>(page,pageSize);
Page<TaskListControllerEntity> page1 = new Page<>(page, pageSize);
QueryWrapper<TaskListControllerEntity> queryWrapper = new QueryWrapper<>();
if (taskName!=null){
if (taskName != null) {
if (!StringUtils.isEmpty(taskName)) {
//构建条件
//第一个为字段名称第二个值为模糊查询传递的值
queryWrapper.like("task_name",taskName);
queryWrapper.like("task_name", taskName);
}
}
if (taskStatus!=null){
if (taskStatus != null) {
if (!StringUtils.isEmpty(taskStatus.toString())) {
//构建条件
//第一个为字段名称第二个值为模糊查询传递的值
queryWrapper.eq("task_status",taskStatus);
queryWrapper.eq("task_status", taskStatus);
}
}
taskListControllerDao.selectPage(page1,queryWrapper);
taskListControllerDao.selectPage(page1, queryWrapper);
List<TaskListControllerEntity> taskEntityList = page1.getRecords();
long num = page1.getTotal();
Map<String,Object> map = new HashMap<>();
if (taskEntityList.size()>0){
map.put("msg",200);//查询成功
map.put("taskEntityList",taskEntityList);
map.put("num",num);
}else {
map.put("msg",501);//查询失败
Map<String, Object> map = new HashMap<>();
if (taskEntityList.size() > 0) {
map.put("msg", 200);//查询成功
map.put("taskEntityList", taskEntityList);
map.put("num", num);
} else {
map.put("msg", 501);//查询失败
}
return map;
}
@ -115,7 +115,7 @@ public class TaskListController {
@ApiOperation("保存")
@LogOperation("保存")
@RequiresPermissions("taskList:tasklistcontroller:save")
public Result save(@RequestBody TaskListControllerDTO dto){
public Result save(@RequestBody TaskListControllerDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
@ -128,7 +128,7 @@ public class TaskListController {
@ApiOperation("修改")
@LogOperation("修改")
@RequiresPermissions("taskList:tasklistcontroller:update")
public Result update(@RequestBody TaskListControllerDTO dto){
public Result update(@RequestBody TaskListControllerDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
@ -141,7 +141,7 @@ public class TaskListController {
@ApiOperation("删除")
@LogOperation("删除")
@RequiresPermissions("taskList:tasklistcontroller:delete")
public Result delete(@RequestBody Long[] ids){
public Result delete(@RequestBody Long[] ids) {
//效验数据
AssertUtils.isArrayEmpty(ids, "id");

View File

@ -20,15 +20,15 @@ public class ShangTangService {
//1.登录
//2.获取token
public String shangtangToken () {
public String shangtangToken() {
String url = "http://10.132.191.54:10270/whale-open-api/tenant/token";
Map<String,Object> map = new HashMap<>();
map.put("accessKey","a1ddCV7z7Jhv0SBGx5O3hblO");
map.put("secretKey","glIixzORLgoFJz0VdF1aXICR");
Map<String, Object> map = new HashMap<>();
map.put("accessKey", "a1ddCV7z7Jhv0SBGx5O3hblO");
map.put("secretKey", "glIixzORLgoFJz0VdF1aXICR");
ResponseEntity<JSONObject> responseEntity;
try {
responseEntity = restTemplate.postForEntity(url,map,JSONObject.class);
responseEntity = restTemplate.postForEntity(url, map, JSONObject.class);
JSONObject body = responseEntity.getBody();
JSONObject data = body.getJSONObject("data");
String token = data.getString("token");
@ -41,7 +41,7 @@ public class ShangTangService {
}
//订阅任务下发接口
public JSONObject subscribe(){
public JSONObject subscribe() {
String token = this.shangtangToken();
String url = "https://10.132.191.54:10270/whale-open-api/subscribe";
@ -49,39 +49,40 @@ public class ShangTangService {
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("token", token);
headers.add("tid","default");
headers.add("tid", "default");
Map<String,Object> map = new HashMap<>();
map.put("callBackUrl","https://15.2.23.163:7010/STapi/project/receive");
Map<String, Object> map = new HashMap<>();
map.put("callBackUrl", "https://15.2.23.163:7010/STapi/project/receive");
// map.put("certPubKey","");
map.put("subscribeType",3);
map.put("subscribeType", 3);
// map.put("taskId","serial");
ResponseEntity<JSONObject> responseEntity;
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(map), headers);
try {
responseEntity = restTemplate.exchange(url, HttpMethod.POST,entity,JSONObject.class);
responseEntity = restTemplate.exchange(url, HttpMethod.POST, entity, JSONObject.class);
JSONObject body = responseEntity.getBody();
return body;
}catch (Exception e){
log.info( "[subscribe] exception:{}",e.getMessage());
} catch (Exception e) {
log.info("[subscribe] exception:{}", e.getMessage());
return null;
}
}
//事件模板分页查询接口
public JSONObject template(){
public JSONObject template() {
String token = this.shangtangToken();
String url = "http://10.132.191.54:10270/whale-open-api/scenario/event/template?pageNum=1&pageSize=1000";
HttpHeaders headers = new HttpHeaders();
headers.add("token",token);
headers.add("tid","default");
headers.add("token", token);
headers.add("tid", "default");
ResponseEntity<JSONObject> responseEntity;
try {
responseEntity = restTemplate.exchange(url,HttpMethod.GET,new HttpEntity<>(headers),JSONObject.class);
JSONObject jsonObject = responseEntity.getBody();
responseEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(headers), JSONObject.class);
JSONObject jsonObject = responseEntity.getBody();
return jsonObject;
} catch (Exception e) {
log.info("[template] exception:{}", e.getMessage());
@ -91,7 +92,7 @@ public class ShangTangService {
}
//场景任务列表查询接口
public JSONObject tasklist(String eventType){
public JSONObject tasklist(String eventType) {
String token = this.shangtangToken();
String url = "http://10.132.191.54:10270/whale-open-api/scenario/event-task/list";
@ -99,7 +100,7 @@ public class ShangTangService {
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("token", token);
headers.add("tid","default");
headers.add("tid", "default");
//需要传的参数
// "eventType": "${appletId}-${eventType}", // 事件唯一标识
// "pageNum": "integer (int32)",
@ -107,43 +108,43 @@ public class ShangTangService {
// "taskName": "string", //任务名称
// "taskSerial": "string", //任务serial
// "taskStatus": "1:运行中,2:已结束,3:异常,4:待启动,5:已停止"
Map<String,Object> map = new HashMap<>();
map.put("eventType",eventType);
map.put("pageNum",1);
map.put("pageSize",100);
Map<String, Object> map = new HashMap<>();
map.put("eventType", eventType);
map.put("pageNum", 1);
map.put("pageSize", 100);
ResponseEntity<JSONObject> responseEntity;
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(map), headers);
try {
responseEntity = restTemplate.exchange(url, HttpMethod.POST,entity,JSONObject.class);
responseEntity = restTemplate.exchange(url, HttpMethod.POST, entity, JSONObject.class);
JSONObject taskListBody = responseEntity.getBody();
return taskListBody;
}catch (Exception e){
log.info( "[tasklist] exception:{}",e.getMessage());
} catch (Exception e) {
log.info("[tasklist] exception:{}", e.getMessage());
return null;
}
}
//场景任务详情查询接口
public JSONObject tasklistDetail(String taskSerial){
public JSONObject tasklistDetail(String taskSerial) {
String token = this.shangtangToken();
String url = "http://10.132.191.54:10270/whale-open-api/scenario/event-task/"+taskSerial;
String url = "http://10.132.191.54:10270/whale-open-api/scenario/event-task/" + taskSerial;
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("token", token);
headers.add("tid","default");
headers.add("tid", "default");
ResponseEntity<JSONObject> responseEntity;
HttpEntity<String> entity = new HttpEntity<>( headers);
HttpEntity<String> entity = new HttpEntity<>(headers);
try {
responseEntity = restTemplate.exchange(url, HttpMethod.GET,entity,JSONObject.class);
responseEntity = restTemplate.exchange(url, HttpMethod.GET, entity, JSONObject.class);
JSONObject taskListDetailBody = responseEntity.getBody();
return taskListDetailBody;
}catch (Exception e){
log.info( "[tasklist] exception:{}",e.getMessage());
} catch (Exception e) {
log.info("[tasklist] exception:{}", e.getMessage());
return null;
}
}

View File

@ -67,6 +67,8 @@ hisense:
gateway:
url: http://devtest-security-app.hismarttv.com:8080
qdyjj:
ipAndPort: 15.2.21.238:9015
##多数据源的配置需要引用renren-dynamic-datasource
#dynamic:

View File

@ -57,6 +57,9 @@ logging:
impl:
persistence:
entity: debug
qdyjj:
ipAndPort: 15.2.21.238:9015
mybatis-plus:
configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

View File

@ -5,12 +5,9 @@ spring:
druid:
#MySQL
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/shangtangapi?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
url: jdbc:mysql://127.0.0.1:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
username: root
password: 123456
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://15.2.21.238:3310/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
# username: root
@ -57,3 +54,6 @@ big_date:
hisense:
gateway:
url: http://devtest-security-app.hismarttv.com:8080
qdyjj:
ipAndPort: 15.2.21.238:9015

View File

@ -47,4 +47,7 @@ big_date:
hisense:
gateway:
url: http://15.72.184.7:8080
url: http://devtest-security-app.hismarttv.com:8080
qdyjj:
ipAndPort: 15.2.21.238:9015

View File

@ -64,6 +64,9 @@ hisense:
gateway:
url: http://devtest-security-app.hismarttv.com:8080
qdyjj:
ipAndPort: 15.2.21.238:9015
##多数据源的配置需要引用renren-dynamic-datasource
#dynamic:

View File

@ -43,4 +43,7 @@ resource:
# 大数据部门相关配置
big_date:
name: 青岛市大数据发展管理局
assignee_role_name: 部门审批人
assignee_role_name: 部门审批人
qdyjj:
ipAndPort: 15.2.21.238:9015

View File

@ -86,4 +86,17 @@ system:
startDay: 2022-04-01
yawei:
enable: true
enable: true
#知识库
zsk:
url:
sign: https://cms.qingdao.gov.cn:9020/api-gateway/jpaas-jags-server/interface/createsign.do
gateway: https://cms.qingdao.gov.cn:9020/api-gateway/jpaas-jags-server/interface/gateway
appid: hxszzt
appkey: 120d6a3cc2cd45096abaa5700cb19d0779d5f22ff683436e6d3a7ff8a8d66f5e8307f31b192281831e9f6dc0b6a1f308
param:
charset: UTF-8
origin: 0
version: 1.0
methodId: jirdGetInfoByCatalog
catalogIds: c0645e03fb7e4cf3842e9ceedd8ab998,f49561afc7204f008c4bb3cd821eb6ba

View File

@ -24,6 +24,7 @@
WHERE
t1.id = #{businessKey}
</select>
<select id="countApplyAll" resultType="java.lang.Long">
SELECT
COUNT( id )
@ -32,6 +33,7 @@
WHERE
approve_status = '通过'
</select>
<select id="getAmountGroupByType" resultType="java.util.Map">
SELECT
tbr.type AS type,
@ -44,6 +46,7 @@
GROUP BY
tbr.type
</select>
<select id="selectDeptApplyCount" resultType="java.util.Map">
SELECT
COUNT(
@ -71,11 +74,13 @@
AND tda.attr_type = '应用领域'
AND tda.del_flag = 0
AND temp.approve_status = '通过'
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tda.attr_value ) - LENGTH( REPLACE ( tda.attr_value, ';', '' ) ) + 1 )
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tda.attr_value ) - LENGTH( REPLACE ( tda.attr_value,
';', '' ) ) + 1 )
GROUP BY
temp.dept_id
LIMIT #{n}
</select>
<select id="selectDeptApply" resultType="java.lang.String">
SELECT DISTINCT
( tda.attr_value )
@ -102,4 +107,15 @@
AND tda.attr_type = '应用领域'
AND tda.del_flag = 0
</select>
<select id="countUserResourceApply" resultType="java.lang.Long">
SELECT
COUNT( id )
FROM
t_ability_application
WHERE
1 = 1
AND del_flag = 0
AND user_id = #{userId}
AND resource_id = #{resourceId}
</select>
</mapper>

View File

@ -104,12 +104,11 @@
<select id="selectWithAttrs" resultMap="resourceDTO">
SELECT
tdr.*,
tda.*,
IFNULL(taa2.approve_status, '未申请') AS "applyState",
IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount",
IFNULL(sd.name, '暂无部门信息') AS "deptName",
IFNULL(sd.name, '暂无部门单位信息') AS "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect",
(IFNULL(tdr.visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(taa.applyCount, 0)+ IFNULL(trc.collectCount, 0)) AS
total
@ -123,21 +122,16 @@
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"
FROM tb_resource_collection WHERE
1 = 1
AND del_flag = 0
AND user_id = #{dto.creator}
GROUP BY resource_id
FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator} GROUP BY resource_id
) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, user_id, approve_status FROM t_ability_application WHERE
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
LEFT JOIN ( SELECT resource_id, user_id, approve_status FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1
AND tdr.del_flag = 0
<if test="dto.type != null and dto.type != ''">
AND tdr.type LIKE CONCAT('%',#{dto.type},'%')
</if>
AND tdr.del_flag = 0
<if test="dto.name != null and dto.name != ''">
AND tdr.name LIKE CONCAT('%',#{dto.name},'%')
</if>
@ -184,9 +178,6 @@
FROM tb_data_resource
WHERE 1 = 1
AND del_flag = 0
<if test="deptId != null and deptId != ''">
AND dept_id = #{deptId}
</if>
GROUP BY type
ORDER BY type
</select>
@ -220,34 +211,67 @@
</select>
<select id="selectDTOById" resultMap="resourceDTO">
<!-- SELECT-->
<!-- tdr.*,-->
<!--&lt;!&ndash; tda.*,&ndash;&gt;-->
<!-- IFNULL(trs.score, 0 ) AS "score",-->
<!-- IFNULL(taa.applyCount, 0 ) AS "applyCount",-->
<!-- IFNULL(trc.collectCount, 0) AS "collectCount",-->
<!-- sd.name as "deptName",-->
<!-- IFNULL(trc2.isCollect, 'false') AS "isCollect",-->
<!-- IFNULL(taa2.approve_status, '未申请') AS "applyState"-->
<!-- FROM-->
<!-- tb_data_resource tdr-->
<!--&lt;!&ndash; LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id&ndash;&gt;-->
<!-- LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP-->
<!-- BY resource_id ) trs ON tdr.id = trs.resource_id-->
<!-- LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =-->
<!-- 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id-->
<!-- LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag-->
<!-- = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id-->
<!-- LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"-->
<!-- FROM tb_resource_collection WHERE-->
<!-- 1 = 1 AND del_flag = 0 AND user_id = #{userId}-->
<!-- GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id-->
<!-- LEFT JOIN ( SELECT resource_id, approve_status FROM t_ability_application WHERE-->
<!-- 1 = 1 AND del_flag = 0 AND user_id = #{userId}-->
<!-- GROUP BY id LIMIT 1) taa2 ON tdr.id = taa2.resource_id-->
<!-- LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id-->
<!-- WHERE 1 = 1-->
<!-- AND tdr.id = #{id}-->
SELECT
tdr.*,
tda.*,
IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount",
sd.name as "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect",
IFNULL(taa2.approve_status, '未申请') AS "applyState"
IFNULL( trs.score, 0 ) AS "score",
IFNULL( taa.applyCount, 0 ) AS "applyCount",
IFNULL( trc.collectCount, 0 ) AS "collectCount",
sd.NAME AS "deptName",
IFNULL( trc2.isCollect, 'false' ) AS "isCollect",
IF
( taa2.approve_status &lt; 1, '未申请', "已申请" ) AS "applyState"
FROM
tb_data_resource tdr
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
BY resource_id ) trs ON tdr.id = trs.resource_id
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"
FROM tb_resource_collection WHERE
1 = 1 AND del_flag = 0 AND user_id = #{userId}
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, approve_status FROM t_ability_application WHERE
1 = 1 AND del_flag = 0 AND user_id = #{userId}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN ( SELECT resource_id, AVG( score ) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trs ON tdr.id = trs.resource_id
LEFT JOIN ( SELECT resource_id, COUNT( id ) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
LEFT JOIN ( SELECT resource_id, COUNT( id ) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
LEFT JOIN (
SELECT
resource_id,
user_id,
( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"
FROM
tb_resource_collection
WHERE
1 = 1
AND del_flag = 0
AND user_id = #{userId}
GROUP BY
resource_id
) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, COUNT( approve_status ) approve_status FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 AND user_id = #{userId} GROUP BY resource_id ) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1
<!-- AND tdr.del_flag = 0-->
WHERE
1 = 1
AND tdr.id = #{id}
</select>
@ -270,11 +294,9 @@
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"
FROM tb_resource_collection WHERE
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, approve_status FROM t_ability_application WHERE
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
LEFT JOIN ( SELECT resource_id, approve_status FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1
@ -323,7 +345,6 @@
LEFT JOIN t_ability_application taa ON tda.data_resource_id = taa.resource_id
AND taa.del_flag = 0
AND taa.user_id = #{userId}
WHERE
1 = 1
AND tda.attr_type = '应用领域'
@ -349,6 +370,7 @@
GROUP BY
type
</select>
<select id="countAllDept" resultType="java.lang.Long">
SELECT
COUNT( DISTINCT dept_id )
@ -372,7 +394,7 @@
sr.id AS "districtId"
FROM
sys_dept sd
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag IN (0 ,5)
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0
<if test="type != null and type != ''">
AND type = #{type}
</if>
@ -399,7 +421,7 @@
IFNULL( tdr.deptCount, 0 ) AS "deptCount"
FROM
sys_dept sd
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag IN (0, 5)
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0
<if test="resourceType != null and resourceType != ''">
AND type = #{resourceType}
</if>
@ -441,7 +463,7 @@
FROM
sys_dept sd
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource
WHERE 1 = 1 AND del_flag IN (0, 5)
WHERE 1 = 1 AND del_flag = 0
<if test="resourceType != null and resourceType != ''">
AND type = #{resourceType}
</if>
@ -457,9 +479,10 @@
GROUP BY
temp2.type
</select>
<select id="countAllVisits" resultType="java.lang.Long">
SELECT
COUNT( visits )
SUM( visits )
FROM
tb_data_resource
</select>

View File

@ -20,44 +20,44 @@
</resultMap>
<update id="deleteByIds">
update tb_resource_car
set del_flag = 1 ,
UPDATE tb_resource_car
SET del_flag = 1 ,
update_date = now()
where 1 = 1
and id in
WHERE 1 = 1
AND id IN
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
<update id="delete4Resource">
update tb_resource_car
set del_flag = 1,
UPDATE tb_resource_car
SET del_flag = 1,
update_date = now()
where 1 = 1
and resource_id in
WHERE 1 = 1
AND resource_id IN
<foreach collection="resourceIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<select id="selectPageWithResource" resultType="io.renren.modules.resourceCar.dto.ResourceCarDTO">
select trc.*
from tb_resource_car trc
SELECT trc.*
FROM tb_resource_car trc
<if test="(params.type != null and params.type != '') or (params.name != null and params.name != '')">
left join tb_data_resource tdr on trc.resource_id = tdr.id and tdr.del_flag != 1
LEFT JOIN tb_data_resource tdr ON trc.resource_id = tdr.id AND tdr.del_flag != 1
</if>
where 1 = 1
and trc.del_flag = 0
and user_id = #{params.userId}
WHERE 1 = 1
AND trc.del_flag = 0
AND user_id = #{params.userId}
<if test="params.name != null and params.name != ''" >
and tdr.name like CONCAT('%',#{params.name},'%')
AND tdr.name LIKE CONCAT('%',#{params.name},'%')
</if>
<if test="params.type != null and params.type != ''">
and tdr.type = #{params.type}
AND tdr.type = #{params.type}
</if>
order by trc.update_date desc, trc.create_date desc
limit ${pageNum}, ${pageSize}
ORDER BY trc.update_date DESC, trc.create_date DESC
LIMIT ${pageNum}, ${pageSize}
</select>
</mapper>