Commit d4222116 authored by chenzhao's avatar chenzhao

投融接口 推送 更新 撤回

parent eac91471
package com.yeejoin.amos.boot.module.hygf.api.Enum;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum FinancingAuditEnum {
待融资审核("FinancingAudit","待融资审核"),
审核不通过("AuditReject","审核不通过"),
待整改("WaitAbarbeitung","待整改"),
整改待推送("AbarbeitungWaitPush","整改待推送"),
审核通过("AuditPass","审核通过"),
放款完成("complete","放款完成");
private String code;
private String name;
/**
* 编码
*/
}
......@@ -45,4 +45,9 @@ public class FinancingInfoDto extends BaseDto {
@ApiModelProperty(value = "状态")
private String status;
@ApiModelProperty(value = "农户id")
private String peasantHouseholdIds;
private String instanceId;
}
package com.yeejoin.amos.boot.module.hygf.api.dto;
import lombok.Data;
@Data
public class WorkflowResultDto {
/**
* WORKFLOW实例ids
*/
String instanceId;
// /**
// * 执行人角色
// */
// String nextExecutorIds;
String executorId;
String executorName;
String createUserId;
/**
* 下一步执行人角色
*/
String nextExecutorIds;
String nextTaskId;
/**
* 下一步执行人用户id
*/
String nextExecuteUserIds;
/**
* 当前节点任务名称
*/
String taskName;
/**
* 下一节点任务名称
*/
String nextNodeName;
/**
* 下一节点code
*/
String nextNodeCode;
String nextNodeKey;
}
package com.yeejoin.amos.boot.module.hygf.api.mapper;
import com.yeejoin.amos.boot.module.hygf.api.dto.FinancingInfoDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.FinancingInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
......@@ -16,4 +18,7 @@ public interface FinancingInfoMapper extends BaseMapper<FinancingInfo> {
List<Map<String,String>> getStationFinancingInfoList();
FinancingInfoDto selectDataInfo(@Param("peasantHouseholdId")Long peasantHouseholdId);
}
package com.yeejoin.amos.boot.module.hygf.api.service;
import com.yeejoin.amos.boot.module.hygf.api.dto.FinancingInfoDto;
import java.util.Map;
/**
* 接口类
*
......@@ -9,4 +13,9 @@ package com.yeejoin.amos.boot.module.hygf.api.service;
*/
public interface IFinancingInfoService {
void rollback(String processId, String peasantHouseholdId);
FinancingInfoDto selectDataInfo(Long sequenceNbr);
}
package com.yeejoin.amos.boot.module.hygf.api.service;
import com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold;
import java.util.List;
/**
* 农户信息接口类
*
......@@ -10,6 +15,5 @@ package com.yeejoin.amos.boot.module.hygf.api.service;
public interface IPeasantHouseholdService {
List<PeasantHousehold> getInfoByIds(String ids);
}
......@@ -8,7 +8,7 @@
hph.sequence_nbr AS sequenceNbr,
hph.peasant_household_no peasantHouseholdNo,
hph.owners_name as ownersName,
hph.project_address as projectAddress,
hph.project_address_name as projectAddress,
hph.regional_companies_name as regionalCompaniesName,
IFNULL(info.`status`,'待推送') as status
FROM
......@@ -16,4 +16,13 @@
WHERE
hph.construction_state= '验收完成'
</select>
<select id="selectDataInfo" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.FinancingInfoDto">
SELECT
hfi.*,
(select instance_id FROM hygf_financing_auditing WHERE peasant_household_id = hfi.peasant_household_id ORDER BY rec_date desc LIMIT 1) as instanceId
FROM
`hygf_financing_info` hfi
WHERE
hfi.peasant_household_id = #{peasantHouseholdId}
</select>
</mapper>
package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.yeejoin.amos.boot.module.hygf.api.util.CommonResponseNewUtil;
import com.yeejoin.amos.boot.module.hygf.api.util.CommonResponseUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
......@@ -83,7 +85,7 @@ public class FinancingInfoController extends BaseController {
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个", notes = "根据sequenceNbr查询单个")
public ResponseModel<FinancingInfoDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(financingInfoServiceImpl.queryBySeq(sequenceNbr));
return ResponseHelper.buildResponse(financingInfoServiceImpl.selectDataInfo(sequenceNbr));
}
/**
......@@ -115,4 +117,13 @@ public class FinancingInfoController extends BaseController {
public ResponseModel<List<FinancingInfoDto>> selectForList() {
return ResponseHelper.buildResponse(financingInfoServiceImpl.queryForFinancingInfoList());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "撤回", notes = "撤回")
@GetMapping(value = "/rollback")
public ResponseModel rollback(String instanceId,String peasantHouseholdId) {
financingInfoServiceImpl.rollback(instanceId,peasantHouseholdId);
return CommonResponseNewUtil.success();
}
}
......@@ -270,7 +270,13 @@ public class PeasantHouseholdController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "农户信息列表根据ids查询", notes = "农户信息列表根据ids查询")
@GetMapping(value = "/getInfoByIds")
public ResponseModel<List<PeasantHousehold>> getInfoByIds(String ids) {
return ResponseHelper.buildResponse(peasantHouseholdServiceImpl.getInfoByIds(ids));
}
......
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.boot.module.hygf.api.Enum.FinancingAuditEnum;
import com.yeejoin.amos.boot.module.hygf.api.dto.FinancingAuditingDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.WorkflowResultDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.BasicGridAcceptance;
import com.yeejoin.amos.boot.module.hygf.api.entity.FinancingInfo;
import com.yeejoin.amos.boot.module.hygf.api.mapper.FinancingInfoMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IFinancingInfoService;
import com.yeejoin.amos.boot.module.hygf.api.dto.FinancingInfoDto;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 服务实现类
......@@ -29,7 +39,13 @@ public class FinancingInfoServiceImpl extends BaseService<FinancingInfoDto,Finan
@Autowired
private FinancingInfoMapper financingInfoMapper;
@Autowired
private WorkflowImpl workflow;
private WorkFlowService workFlowService;
@Autowired
private WorkflowImpl workflow;
@Autowired
private FinancingAuditingServiceImpl financingAuditingService;
private static String PROCESSKEY="StationFinancing";
public Page<Map<String, String>> queryForFinancingInfoPage(Page<Map<String, String>> page) {
......@@ -49,8 +65,76 @@ public class FinancingInfoServiceImpl extends BaseService<FinancingInfoDto,Finan
return this.queryForList("" , false);
}
@Transactional
public FinancingInfoDto saveModel(FinancingInfoDto model) {
this.createWithModel(model);
return null;
List<String> ids ;
if (model.getPeasantHouseholdIds().contains(",")) {
ids= Arrays.asList(model.getPeasantHouseholdIds().split(","));
}else {
ids= Arrays.asList(new String[]{model.getPeasantHouseholdIds()});
}
ids.stream().forEach(e->{
LambdaQueryWrapper<FinancingInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(FinancingInfo::getPeasantHouseholdId,Long.valueOf(e));
List<FinancingInfo> financingInfos = this.getBaseMapper().selectList(queryWrapper);
if (CollectionUtils.isEmpty(financingInfos)){
model.setStatus(FinancingAuditEnum.待融资审核.getName());
model.setPeasantHouseholdId(Long.valueOf(e));
FinancingInfoDto financingInfoDto = new FinancingInfoDto();
BeanUtils.copyProperties(model,financingInfoDto);
financingInfoDto.setSequenceNbr(null);
this.createWithModel(financingInfoDto);
}
//开启工作流 并执行一步
ActWorkflowBatchDTO actWorkflowBatchDTO = new ActWorkflowBatchDTO();
List<ActWorkflowStartDTO> list = new ArrayList<>();
ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setProcessDefinitionKey(PROCESSKEY);
dto.setBusinessKey(String.valueOf(new Date().getTime()));
dto.setCompleteFirstTask(true);
list.add(dto);
actWorkflowBatchDTO.setProcess(list);
List<ProcessTaskDTO> processTaskDTOS = workFlowService.startBatch(actWorkflowBatchDTO);
List<WorkflowResultDto> workflowResultDtos = workFlowService.buildWorkFlowInfo(processTaskDTOS);
WorkflowResultDto workflowResultDto = workflowResultDtos.get(0);
FinancingAuditingDto financingAuditingDto = new FinancingAuditingDto();
BeanUtils.copyProperties(workflowResultDto,financingAuditingDto);
financingAuditingDto.setPeasantHouseholdId(Long.valueOf(e));
financingAuditingDto.setPromoter(RequestContext.getExeUserId());
financingAuditingService.createWithModel(financingAuditingDto);
});
return model;
}
@Override
public void rollback(String processId, String peasantHouseholdId) {
workFlowService.stopProcess(processId);
LambdaQueryWrapper<FinancingInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(FinancingInfo::getPeasantHouseholdId,peasantHouseholdId);
List<FinancingInfo> financingInfos = this.getBaseMapper().selectList(queryWrapper);
if (!CollectionUtils.isEmpty(financingInfos)){
FinancingInfo financingInfo = financingInfos.get(0);
financingInfo.setStatus("待推送");
financingInfo.setFinancingCompaniesCode(null);
financingInfo.setFinancingCompaniesSeq(null);
financingInfo.setFinancingCompaniesName(null);
this.updateById(financingInfo);
}
}
@Override
public FinancingInfoDto selectDataInfo(Long peasantHouseholdId) {
return this.getBaseMapper().selectDataInfo(peasantHouseholdId);
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.hygf.api.Enum.ArrivalStateeEnum;
import com.yeejoin.amos.boot.module.hygf.api.Enum.CodeEnum;
......@@ -667,4 +670,12 @@ public class PeasantHouseholdServiceImpl extends BaseService<PeasantHouseholdDto
return (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000;
}
@Override
public List<PeasantHousehold> getInfoByIds(String ids) {
LambdaQueryWrapper<PeasantHousehold> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(BaseEntity::getSequenceNbr,Arrays.asList(ids.split(",")));
queryWrapper.eq(BaseEntity::getIsDelete,0);
return this.getBaseMapper().selectList(queryWrapper);
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.hygf.api.dto.WorkflowResultDto;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Slf4j
public class WorkFlowService {
/***
* 开启并执行一步 支持批量
*
* */
public List<ProcessTaskDTO> startBatch(ActWorkflowBatchDTO params) {
List<ProcessTaskDTO> processTasks;
try {
log.info("开始前请求工作流启动接口:/start/batch,请求参数:{}", JSONObject.toJSONString(params));
processTasks = FeignUtil.remoteCall(() -> Workflow.taskV2Client.startForBatch(params));
} catch (Exception e) {
log.error("调用工作流批量启动失败", e);
throw new RuntimeException("调用工作流批量启动失败");
}
return processTasks;
}
public ProcessInstanceDTO stopProcess(String processInstanceId) {
ProcessInstanceDTO processInstanceDTO ;
try {
log.info("开始前请求工作流停止接口:stopProcess,请求参数:{}", processInstanceId);
processInstanceDTO = FeignUtil.remoteCall(() -> Workflow.taskV2Client.stopProcess(processInstanceId));
} catch (Exception e) {
log.error("调用工作流批量停止失败", e);
throw new RuntimeException("调用工作流批量启动失败");
}
return processInstanceDTO;
}
/***
* 执行
*
* */
public ProcessTaskDTO complete(String taskId, TaskResultDTO data) {
ProcessTaskDTO processTaskDTO;
try {
log.info("开始前请求工作流完成任务接口:/complete/standard/{taskId},请求参数:{},{}", taskId, JSONObject.toJSONString(data));
processTaskDTO = FeignUtil.remoteCall(() -> Workflow.taskV2Client.completeByTaskFroStandard(taskId, data));
} catch (Exception e) {
log.error("调用工作流完成任务接口失败", e);
throw new RuntimeException("调用工作流完成任务接口失败");
}
return processTaskDTO;
}
public List<WorkflowResultDto> buildWorkFlowInfo(List<ProcessTaskDTO> processTaskDTOS) {
List<WorkflowResultDto> workflowResultDtoList = new ArrayList<>();
processTaskDTOS.forEach(item -> {
WorkflowResultDto workflowResultDto = new WorkflowResultDto();
workflowResultDto.setInstanceId(item.getProcessInstance().getId());
workflowResultDto.setTaskName(item.getTask().getName());
// workflowResultDto.setNextExecutorIds(String.join(",", item.getCandidateGroups()));
workflowResultDto.setExecutorId(item.getExecutor().getUserId());
workflowResultDto.setExecutorName(item.getExecutor().getRealName());
if (!CollectionUtils.isEmpty(item.getNextTask())) {
ActTaskDTO actTaskDTO = item.getNextTask().get(0);
workflowResultDto.setNextTaskId(actTaskDTO.getId());
workflowResultDto.setNextNodeKey(actTaskDTO.getKey()); // 工作流字段还未添加
workflowResultDto.setNextNodeName(actTaskDTO.getName());
List<String> nextGroups = item.getNextCandidateGroups().get(actTaskDTO.getId());
String join = String.join(",", nextGroups);
workflowResultDto.setNextExecutorIds(join);
List<String> nextUserIds = item.getNextTaskExecutor().get(actTaskDTO.getId()).stream().map(AgencyUserModel::getUserId).collect(Collectors.toList());
String nextUserIdsString = String.join(",", nextUserIds);
workflowResultDto.setNextExecuteUserIds(nextUserIdsString);
}
workflowResultDtoList.add(workflowResultDto);
});
return workflowResultDtoList;
}
}
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