| | |
| | | package cn.gistack.sm.patrol.service.impl; |
| | | |
| | | import cn.gistack.flow.core.constant.ProcessConstant; |
| | | import cn.gistack.flow.core.entity.BladeFlow; |
| | | import cn.gistack.flow.core.feign.IFlowClient; |
| | | import cn.gistack.flow.core.utils.FlowUtil; |
| | | import cn.gistack.flow.core.utils.TaskUtil; |
| | | import cn.gistack.sm.patrol.dto.PatrolGroupDTO; |
| | | import cn.gistack.sm.patrol.entity.PatrolGroupItem; |
| | | import cn.gistack.sm.patrol.entity.PatrolRecord; |
| | | import cn.gistack.sm.patrol.entity.PatrolType; |
| | | import cn.gistack.sm.patrol.mapper.PatrolRecordMapper; |
| | | import cn.gistack.sm.patrol.service.IPatrolGroupItemService; |
| | | import cn.gistack.sm.patrol.service.IPatrolRecordService; |
| | |
| | | import cn.gistack.sm.patrol.vo.PatrolRecordVO; |
| | | import cn.gistack.sm.patrol.vo.RecordBatchVO; |
| | | import cn.gistack.sm.patrol.vo.RecordVO; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import cn.gistack.sm.sjztmd.service.IAttResManagePersonService; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.ObjectUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | @AllArgsConstructor |
| | | public class PatrolRecordServiceImpl extends BaseServiceImpl<PatrolRecordMapper, PatrolRecord> implements IPatrolRecordService { |
| | | IPatrolGroupItemService patrolGroupItemService; |
| | | |
| | | private final IAttResManagePersonService attResManagePersonService; |
| | | private final IFlowClient flowClient; |
| | | |
| | | @Override |
| | | public IPage<PatrolRecord> selectPatrolRecord(IPage<PatrolRecord> page, PatrolRecordVO patrolRecord) { |
| | |
| | | public PatrolRecordVO getHandleRecord(PatrolRecord patrolRecord) { |
| | | return baseMapper.getHandleRecord(patrolRecord); |
| | | } |
| | | |
| | | @Override |
| | | public void startProcess(PatrolRecordVO record,String resId) { |
| | | |
| | | String businessTable = FlowUtil.getBusinessTable(ProcessConstant.PATROL_KEY); |
| | | |
| | | //异常,未解决需要开启流程 |
| | | if (record.getStatus() == 2 && record.getSolution().equals("2")) { |
| | | |
| | | // List<PersonVO> managePersonList = attResManagePersonService.getManagePersonList(resId, "4"); |
| | | //没主键 |
| | | if (Func.isEmpty(record.getId())) { |
| | | save(record); |
| | | |
| | | Kv variables = Kv.create() |
| | | //设置创建人 |
| | | .set(ProcessConstant.TASK_VARIABLE_CREATE_USER, AuthUtil.getUserId()) |
| | | //指定责任人,因为不一定是巡查责任完成的任务,需要前端传递taskUser |
| | | .set("taskUser", TaskUtil.getTaskUser(record.getTaskUser())); |
| | | R<BladeFlow> result = flowClient.startProcessInstanceById(record.getProcessDefinitionId(), FlowUtil.getBusinessKey(businessTable, String.valueOf(record.getId())), variables); |
| | | |
| | | if (result.isSuccess()) { |
| | | log.debug("流程已启动,流程ID:" + result.getData().getProcessInstanceId()); |
| | | // 返回流程id写入 |
| | | record.setProcessInstanceId(result.getData().getProcessInstanceId()); |
| | | updateById(record); |
| | | } else { |
| | | throw new ServiceException("开启流程失败"); |
| | | } |
| | | } else { |
| | | updateById(record); |
| | | } |
| | | |
| | | } else { |
| | | save(record); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public PatrolRecordVO customizeGetById(String id) { |
| | | return baseMapper.getDetail(id); |
| | | } |
| | | } |