This commit is contained in:
wangliwen 2022-06-03 10:55:59 +08:00
parent fb9bb36175
commit 21dae97a3e
6 changed files with 103 additions and 23 deletions

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

@ -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

@ -74,7 +74,8 @@
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}
@ -106,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

@ -211,33 +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 LIMIT 1) 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 id ) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1
WHERE
1 = 1
AND tdr.id = #{id}
</select>