package cn.autoform.web.service.process.impl; import java.util.List; import java.util.Map; import java.util.concurrent.TimeoutException; import javax.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import cn.autoform.db.entity.ProcessTask; import cn.autoform.db.entity.ProcessTaskExtend; import cn.autoform.db.exten.Process; import cn.autoform.util.tool.JSONTool; import cn.autoform.web.client.WorkflowClient; import cn.autoform.web.client.util.WorkflowTool; import cn.autoform.web.mapper.process.ProcessTaskMapper; import cn.autoform.web.service.process.ProcessTaskService; import lombok.extern.slf4j.Slf4j; import net.sf.json.JSONObject; @Slf4j @Service("processTaskServiceImpl") public class ProcessTaskServiceImpl implements ProcessTaskService{ @Resource private ProcessTaskMapper processTaskMapper; /** * 参数使用 */ @Autowired private WorkflowTool workflowTool; //流程对接service @Autowired private WorkflowClient workflowClient; @SuppressWarnings("unchecked") @Transactional @Override public ProcessTaskExtend insertList(String jsonStr) throws TimeoutException { log.debug("进入本端添加待办"); ProcessTaskExtend pros = new ProcessTaskExtend(); JSONObject jsonObject = JSONObject.fromObject(jsonStr); Map result = null; Process process = workflowTool.getProcess(jsonObject); List list = null; //从工作流获取所有待办 result =(Map) workflowClient.instSeacheHandle(process).get("data"); System.out.println("返回结果"+JSONTool.toJson(result)); try{ list = JSONTool.toList(JSONTool.toJson(result.get("data")), ProcessTask.class); System.out.println("转换后:"+JSONTool.toJson(list)); }catch(NullPointerException e){ return null; } //删除过期待办 //processTaskMapper.deleteTask(); //添加新待办 int num = 0; // if(list.size()>0){ // System.out.println("sdf:"+list.size()); // for(ProcessTask pro: list){ // num += processTaskMapper.insertList(pro); // } // // System.out.println("进入添加"+num); // } pros.setPages(result.get("pages").toString()); pros.setProcessTaskList(list); System.out.println("最后结果:"+JSONTool.toJson(pros)); return pros; } /** * 分页待办 */ public List selectPage(){ return null; } }