Merge branch 'dev'

This commit is contained in:
wangliwen 2022-11-28 09:03:12 +08:00
commit e74212ea27
6 changed files with 452 additions and 21 deletions

View File

@ -115,7 +115,7 @@ public class AbilityCenterControllerV2 {
abilityBatchApplicationDTO.setApplyFlag(applyFlag); // 同一次的申请标识
final Optional<SysDeptDTO> deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName));
final UserDetail user = SecurityUser.getUser();
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
/*switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case TSINGTAO: { // 青岛市局 异步会死锁
deal(abilityBatchApplicationDTO, deptDTO, applyFlag, user);
}
@ -123,7 +123,8 @@ public class AbilityCenterControllerV2 {
default: {
executor.execute(() -> deal(abilityBatchApplicationDTO, deptDTO, applyFlag, user));
}
}
}*/
executor.execute(() -> deal(abilityBatchApplicationDTO, deptDTO, applyFlag, user));
return new Result().ok(LocalDateTime.now().toString());
}
@ -144,7 +145,7 @@ public class AbilityCenterControllerV2 {
logger.info("申请入参{}", JSON.toJSONString(abilityBatchApplicationDTO));
final Optional<SysDeptDTO> deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName));
final UserDetail user = SecurityUser.getUser();
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
/*switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case TSINGTAO: { // 青岛市局 异步会死锁
deal(abilityBatchApplicationDTO, deptDTO, applyFlag, user);
}
@ -153,32 +154,34 @@ public class AbilityCenterControllerV2 {
//executor.execute(() -> deal(abilityBatchApplicationDTO, deptDTO, applyFlag, user));
deal(abilityBatchApplicationDTO, deptDTO, applyFlag, user);
}
}
}*/
deal(abilityBatchApplicationDTO, deptDTO, applyFlag, user);
return new Result().ok(LocalDateTime.now().toString());
}
private void deal(TAbilityBatchApplicationDTO abilityBatchApplicationDTO, Optional<SysDeptDTO> deptDTO, String applyFlag, UserDetail user) {
List<TAbilityApplicationDTO> tAbilityApplicationDTOList = abilityBatchApplicationDTO.getSystem().stream().map(index -> {
//if (tAbilityApplicationService.countUserResourceApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId"))) > 0) { // 防止重复发起申请
// logger.error("重复发起申请");
// return null;
//}
//2022-11-22 资源重复申请判断更新
if (index.containsKey("channelId")) {
String today = DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN);
if (tAbilityApplicationService.countUserCameraApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId")), today) > 0) {
logger.error("重复发起申请");
return null;
}
} else {
if (tAbilityApplicationService.countUserResourceApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId"))) > 0) { // 防止重复发起申请
logger.error("重复发起申请");
return null;
}
}
//2022-11-22 资源重复申请判断更新
//if (index.containsKey("channelId")) {
// String today = DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN);
// if (tAbilityApplicationService.countUserCameraApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId")), today) > 0) {
// logger.error("重复发起申请");
// return null;
// }
//} else {
// if (tAbilityApplicationService.countUserResourceApply(SecurityUser.getUserId(), Long.valueOf(index.get("resourceId"))) > 0) { // 防止重复发起申请
// logger.error("重复发起申请");
// return null;
// }
//}
TAbilityApplicationDTO tAbilityApplicationDTO = new TAbilityApplicationDTO();
tAbilityApplicationDTO.setArea(abilityBatchApplicationDTO.getArea());
tAbilityApplicationDTO.setAttachment(abilityBatchApplicationDTO.getAttachment());

View File

@ -554,4 +554,67 @@ public class TAbilityApplicationController {
}
@GetMapping("/getDistrictFundStatement")
@ApiOperation("获取区市资金报表")
@LogOperation("获取区市资金报表")
public Result getDistrictFundStatement (Map<String, Object> params) {
return new Result().ok(tAbilityApplicationService.getDistrictFundStatement(params));
}
@GetMapping("/getComponentFundStatement")
@ApiOperation("获取组件节约资金列表")
@LogOperation("获取组件节约资金列表")
public Result getComponentFundStatement (Map<String, Object> params) {
return new Result().ok(tAbilityApplicationService.getComponentFundStatement(params));
}
@GetMapping("/getResourceFundStatement")
@ApiOperation("获取应用资源节约资金列表")
@LogOperation("获取应用资源节约资金列表")
public Result getResourceFundStatement (Map<String, Object> params) {
return new Result().ok(tAbilityApplicationService.getResourceFundStatement(params));
}
@GetMapping("/getInfrastructureFundStatement")
@ApiOperation("获取基础设施节约资金列表")
@LogOperation("获取基础设施节约资金列表")
public Result getInfrastructureFundStatement (Map<String, Object> params) {
return new Result().ok(tAbilityApplicationService.getInfrastructureFundStatement(params));
}
@GetMapping("/getProvideDeptFundStatement")
@ApiOperation("获取提供部门节约资金列表")
@LogOperation("获取提供部门节约资金列表")
public Result getProvideDeptFundStatement (Map<String, Object> params) {
return new Result().ok(tAbilityApplicationService.getProvideDeptFundStatement(params));
}
@GetMapping("/getApplyDeptFundStatement")
@ApiOperation("获取申请部门节约资金列表")
@LogOperation("获取申请部门节约资金列表")
public Result getApplyDeptFundStatement (Map<String, Object> params) {
return new Result().ok(tAbilityApplicationService.getApplyDeptFundStatement(params));
}
@GetMapping("/getProvideDistrictFundStatement")
@ApiOperation("获取提供区市节约资金列表")
@LogOperation("获取提供区市节约资金列表")
public Result getProvideDistrictFundStatement (Map<String, Object> params) {
return new Result().ok(tAbilityApplicationService.getProvideDistrictFundStatement(params));
}
@GetMapping("/getApplyDistrictFundStatement")
@ApiOperation("获取申请区市节约资金列表")
@LogOperation("获取申请区市节约资金列表")
public Result getApplyDistrictFundStatement (Map<String, Object> params) {
return new Result().ok(tAbilityApplicationService.getApplyDistrictFundStatement(params));
}
}

View File

@ -64,4 +64,22 @@ public interface TAbilityApplicationDao extends BaseDao<TAbilityApplicationEntit
List<Map> exportFundStatementTable(@Param("params") Map<String, Object> params);
Long getFundStatementCount(@Param("params") Map<String, Object> params);
List<Map> getDistrictFundStatement();
List<Map> getCenusDistrictList();
List<Map> getComponentFundStatement();
List<Map> getResourceFundStatement();
List<Map> getInfrastructureFundStatement();
List<Map> getProvideDeptFundStatement();
List<Map> getApplyDeptFundStatement();
List<Map> getProvideDistrictFundStatement();
List<Map> getApplyDistrictFundStatement();
}

View File

@ -68,4 +68,20 @@ public interface TAbilityApplicationService extends CrudService<TAbilityApplicat
Object getFundStatement(Map<String, Object> params);
Object exportFundStatementTable(Map<String, Object> params);
Object getDistrictFundStatement(Map<String, Object> params);
Object getComponentFundStatement(Map<String, Object> params);
Object getResourceFundStatement(Map<String, Object> params);
Object getInfrastructureFundStatement(Map<String, Object> params);
Object getProvideDeptFundStatement(Map<String, Object> params);
Object getApplyDeptFundStatement(Map<String, Object> params);
Object getProvideDistrictFundStatement(Map<String, Object> params);
Object getApplyDistrictFundStatement(Map<String, Object> params);
}

View File

@ -1,16 +1,21 @@
package io.renren.modules.processForm.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.utils.ConvertUtils;
import io.renren.common.utils.DateUtils;
import io.renren.modules.activiti.service.ActRunningService;
import io.renren.modules.processForm.dao.TAbilityApplicationDao;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.entity.TAbilityApplicationEntity;
import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.security.user.UserDetail;
import net.sf.jsqlparser.statement.create.table.Index;
import org.activiti.engine.HistoryService;
import org.activiti.engine.history.HistoricProcessInstance;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -34,6 +39,9 @@ public class TAbilityApplicationServiceImpl extends CrudServiceImpl<TAbilityAppl
@Autowired
private TAbilityApplicationDao abilityApplicationDao;
@Autowired
protected HistoryService historyService;
@Override
public QueryWrapper<TAbilityApplicationEntity> getWrapper(Map<String, Object> params) {
QueryWrapper<TAbilityApplicationEntity> wrapper = new QueryWrapper<>();
@ -149,6 +157,29 @@ public class TAbilityApplicationServiceImpl extends CrudServiceImpl<TAbilityAppl
UserDetail userDetail = SecurityUser.getUser();
String currentTime = DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN);
List<Map> cameraList = abilityApplicationDao.getApplyCameraList(userDetail.getId(), currentTime);
cameraList.forEach(index -> {
HistoricProcessInstance processInstanceDTO =
historyService.createHistoricProcessInstanceQuery().processInstanceId(index.get("instanceId").toString()).includeProcessVariables().singleResult();
if (processInstanceDTO != null) {
logger.info(processInstanceDTO.getProcessVariables().toString());
if (processInstanceDTO.getProcessVariables().containsKey("backToFirst")) {
try {
Boolean backToFirst = Boolean.parseBoolean(processInstanceDTO.getProcessVariables().getOrDefault("backToFirst", "false").toString());
if (backToFirst.equals(Boolean.TRUE)) {
index.put("backToFirst", "true");
} else {
index.put("backToFirst", "false");
}
} catch (Exception exception) {
logger.info(exception.toString());
}
} else {
index.put("backToFirst", "false");
}
} else {
index.put("backToFirst", "");
}
});
return cameraList.isEmpty() ? new ArrayList<>() : cameraList;
}
@ -179,5 +210,84 @@ public class TAbilityApplicationServiceImpl extends CrudServiceImpl<TAbilityAppl
return abilityApplicationDao.exportFundStatementTable(params);
}
@Override
public Object getDistrictFundStatement(Map<String, Object> params) {
List<Map> cenusDistrictList = abilityApplicationDao.getCenusDistrictList();
List<Map> resultList = new ArrayList<>();
resultList.addAll(cenusDistrictList);
return resultList;
}
@Override
public Object getComponentFundStatement(Map<String, Object> params) {
List<Map> cenusDistrictList = abilityApplicationDao.getComponentFundStatement();
Long total = 0L;
for (Map map : cenusDistrictList) {
total = total + Long.parseLong(map.get("applyPrice").toString());
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("list", cenusDistrictList);
resultMap.put("total", total);
return resultMap;
}
@Override
public Object getResourceFundStatement(Map<String, Object> params) {
List<Map> list = abilityApplicationDao.getResourceFundStatement();
Long total = 0L;
for (Map map : list) {
total = total + Long.parseLong(map.get("applyPrice").toString());
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("list", list);
resultMap.put("total", total);
return resultMap;
}
@Override
public Object getInfrastructureFundStatement(Map<String, Object> params) {
List<Map> list = abilityApplicationDao.getInfrastructureFundStatement();
Long total = 0L;
for (Map map : list) {
total = total + Long.parseLong(map.get("applyPrice").toString());
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("list", list);
resultMap.put("total", total);
return resultMap;
}
@Override
public Object getProvideDeptFundStatement(Map<String, Object> params) {
List<Map> deptList = abilityApplicationDao.getProvideDeptFundStatement();
List<Map> resultList = new ArrayList<>();
resultList.addAll(deptList);
return resultList;
}
@Override
public Object getApplyDeptFundStatement(Map<String, Object> params) {
List<Map> deptList = abilityApplicationDao.getApplyDeptFundStatement();
List<Map> resultList = new ArrayList<>();
resultList.addAll(deptList);
return resultList;
}
@Override
public Object getProvideDistrictFundStatement(Map<String, Object> params) {
List<Map> deptList = abilityApplicationDao.getProvideDistrictFundStatement();
List<Map> resultList = new ArrayList<>();
resultList.addAll(deptList);
return resultList;
}
@Override
public Object getApplyDistrictFundStatement(Map<String, Object> params) {
List<Map> deptList = abilityApplicationDao.getApplyDistrictFundStatement();
List<Map> resultList = new ArrayList<>();
resultList.addAll(deptList);
return resultList;
}
}

View File

@ -697,4 +697,225 @@
</if>
) temp
</select>
<select id="getDistrictFundStatement" resultType="java.util.Map">
( SELECT
srg.id AS "districtId ",
srg.NAME AS "districtName",
IFNULL( COUNT( taa.apply_price ), 0 ) AS "applyPrice",
srg.sort
FROM
( SELECT id, NAME, sort FROM sys_region WHERE tree_level = 3 AND sort <= 9 ) srg
LEFT JOIN sys_dept sd ON sd.district = srg.id
LEFT JOIN sys_user su ON su.dept_id = sd.id
LEFT JOIN t_ability_application taa ON taa.user_id = su.id
WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY
srg.id
) UNION ALL
SELECT
id AS "districtId",
NAME AS "districtName",
0 AS "applyPrice",
sort
FROM
sys_region
WHERE
tree_level = 3
AND 9 >= sort
AND id NOT IN (
SELECT
srg.id
FROM
( SELECT id, NAME, sort FROM sys_region WHERE tree_level = 3 AND sort <= 9 ) srg
LEFT JOIN sys_dept sd ON sd.district = srg.id
LEFT JOIN sys_user su ON su.dept_id = sd.id
LEFT JOIN t_ability_application taa ON taa.user_id = su.id
WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY
srg.id
) ORDER BY sort
</select>
<select id="getCenusDistrictList" resultType="java.util.Map">
SELECT id AS "districtId", NAME AS "districtName", 0 AS "applyPrice" FROM sys_region WHERE tree_level = 3 AND 9 >= sort
</select>
<select id="getComponentFundStatement" resultType="java.util.Map">
SELECT
tda.attr_value AS "resourceType",
COUNT( tdr.id ) AS "resourceAmount",
SUM( taa.price ) AS "applyPrice",
SUM( taa.applyCount ) AS "applyCount"
FROM
tb_data_attr tda
LEFT JOIN tb_data_resource tdr ON tdr.id = tda.data_resource_id
LEFT JOIN (
SELECT
resource_id,
SUM( apply_price ) AS "price",
COUNT( resource_id ) AS "applyCount"
FROM
t_ability_application taa
WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY
resource_id
) taa ON taa.resource_id = tdr.id
WHERE
tda.del_flag = 0
AND tdr.del_flag = 0
AND tda.attr_type = '组件类型'
GROUP BY
tda.attr_value
</select>
<select id="getResourceFundStatement" resultType="java.util.Map">
SELECT
tdr.name AS "resourceName",
sd.name AS "deptName",
taa.price AS "applyPrice",
taa.applyCount AS "applyCount"
FROM
(
SELECT
resource_id,
SUM( apply_price ) AS "price",
COUNT( resource_id ) AS "applyCount"
FROM
t_ability_application taa
WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY
resource_id
) taa
LEFT JOIN tb_data_resource tdr ON taa.resource_id = tdr.id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE
tdr.del_flag = 0
ORDER BY taa.price DESC
</select>
<select id="getInfrastructureFundStatement" resultType="java.util.Map">
SELECT
'会客厅' AS "resourceName",
SUM( apply_price ) AS "applyPrice"
FROM
t_meetingroom_book tmb
WHERE
tmb.state IN (
0,
2)
</select>
<select id="getProvideDeptFundStatement" resultType="java.util.Map">
SELECT
sd.id AS "deptId",
sd.NAME AS "deptName",
COUNT( tdr.id ) AS "resourceCount",
SUM( taa.price ) AS "applyPrice"
FROM
sys_dept sd
LEFT JOIN tb_data_resource tdr ON tdr.dept_id = sd.id
LEFT JOIN (
SELECT
resource_id,
SUM( apply_price ) AS "price",
COUNT( resource_id ) AS "applyCount"
FROM
t_ability_application taa
WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY
resource_id
) taa ON taa.resource_id = tdr.id
WHERE
tdr.del_flag = 0
AND sd.type = 2
GROUP BY
sd.id
ORDER BY
applyPrice DESC
LIMIT 10
</select>
<select id="getApplyDeptFundStatement" resultType="java.util.Map">
SELECT
sd.id AS "deptId",
sd.NAME AS "deptName",
SUM( taa.applyCount ) AS "applyCount",
SUM( taa.price ) AS "applyPrice"
FROM
(
SELECT
SUM( apply_price ) AS "price",
COUNT( id ) AS "applyCount",
user_id
FROM
t_ability_application taa
WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY
user_id
) taa
LEFT JOIN sys_user su ON taa.user_id = su.id
LEFT JOIN sys_dept sd ON su.dept_id = sd.id
WHERE
sd.type = 2
GROUP BY
sd.id
ORDER BY
applyPrice DESC
LIMIT 10
</select>
<select id="getProvideDistrictFundStatement" resultType="java.util.Map">
SELECT
srg.id AS "districtId ",
srg.NAME AS "districtName",
IFNULL(SUM(taa.applyCount), 0) AS "applyCount",
IFNULL( SUM( taa.apply_price ), 0 ) AS "applyPrice",
srg.sort
FROM
( SELECT id, NAME, sort FROM sys_region WHERE tree_level = 3 AND sort <= 9 ) srg
LEFT JOIN sys_dept sd ON sd.district = srg.id
LEFT JOIN sys_user su ON su.dept_id = sd.id
LEFT JOIN (SELECT user_id, SUM(apply_price) AS "apply_price", COUNT(id) AS "applyCount" FROM t_ability_application taa WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' ) GROUP BY user_id ) taa ON taa.user_id = su.id
GROUP BY
srg.id
ORDER BY srg.sort
</select>
<select id="getApplyDistrictFundStatement" resultType="java.util.Map">
SELECT
srg.id AS "districtId ",
srg.NAME AS "districtName",
IFNULL(SUM(taa.applyCount), 0) AS "applyCount",
IFNULL( SUM(taa.apply_price ), 0 ) AS "applyPrice",
srg.sort
FROM
( SELECT id, NAME, sort FROM sys_region WHERE tree_level = 3 AND sort <= 9 ) srg
LEFT JOIN sys_dept sd ON sd.district = srg.id
LEFT JOIN tb_data_resource tdr ON tdr.dept_id = sd.id
LEFT JOIN (SELECT resource_id, SUM(apply_price) AS "apply_price", COUNT(id) AS "applyCount" FROM t_ability_application taa WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' ) GROUP BY resource_id ) taa ON taa.resource_id = tdr.id
GROUP BY
srg.id
ORDER BY srg.sort
</select>
</mapper>