ActTaskController.java 31.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786
/**
 * Copyright © 2015-2018 ODM All rights reserved.
 */
package com.thinkgem.jeesite.modules.act.web;
import java.io.File;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.activiti.engine.HistoryService;
import org.activiti.engine.task.Task;
import org.activiti.tracelog.ActivitiLog;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.act.entity.Act;
import com.thinkgem.jeesite.modules.act.service.ActProcessService;
import com.thinkgem.jeesite.modules.act.service.ActTaskService;
import com.thinkgem.jeesite.modules.act.utils.ActUtils;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZdjbxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusFdcq2;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusQlr;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusSlsq;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusYwr;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseHService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseZdjbxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusCfdjService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusDyaqService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusFdcq1Service;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusFdcq2Service;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusJsydsyqService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusQlrService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusSlsqService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusTdsyqService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusYgdjService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusYwrService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusYydjService;
import com.thinkgem.jeesite.modules.reg.utils.RegUtils;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import com.thinkgem.jeesite.modules.ycsl.entity.YcslJbxx;
import com.thinkgem.jeesite.modules.ycsl.service.YcslJbxxService;
import com.thinkgem.jeesite.modules.sys.entity.Dict;
import com.thinkgem.jeesite.modules.sys.entity.Office;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.service.OfficeService;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;

/**
 * 流程个人任务相关Controller
 * @author ThinkGem
 * @version 2013-11-03
 */
@Controller
@RequestMapping(value = "${adminPath}/act/task")
public class ActTaskController extends BaseController {

	@Autowired
	private ActTaskService actTaskService;
	@Autowired
	private RegBusSlsqService regBusSlsqService;
	@Autowired
	private ActProcessService actProcessService;
	@Autowired
	private HistoryService historyService;
	@Autowired
	private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
	@Autowired
	private RegBaseZdjbxxService regBaseZdjbxxService;
	@Autowired
	private RegBusCfdjService regBusCfdjService;
	@Autowired
	private RegBusQlrService regBusQlrService;
	@Autowired
	private RegBusYwrService regBusYwrService;
	@Autowired
	private RegBaseHService regBaseHService;
	@Autowired
	private RegBusYydjService regBusYydjService;
	@Autowired
	private RegBusFdcq2Service regBusFdcq2Service;
	@Autowired
	private RegBusFdcq1Service regBusFdcq1Service;
	@Autowired
	private RegBusJsydsyqService regBusJsydsyqService;
	@Autowired
	private RegBusYgdjService regBusYgdjService;
	@Autowired
	private RegBusDyaqService regBusDyaqService;
	@Autowired
	private RegBusTdsyqService regBusTdsyqService;
	@Autowired
	private OfficeService officeService;
	@Autowired
	private YcslJbxxService ycslJbxxService;
	
	/**
	 * 获取待办列表
	 * @param procDefKey 流程定义标识
	 * @return
	 */
	@RequestMapping(value = {"todo", ""})
	public String todoList(Act act, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
		String n = request.getParameter("n");
		String s = request.getParameter("s");
		/** 分页之前代码
		List<Act> list = actTaskService.todoList(act);
		model.addAttribute("list", list);
		if (UserUtils.getPrincipal().isMobileLogin()){
			return renderString(response, list);
		}
		*/
		//add point for trace the claim operation issue.
		ActivitiLog.debug("Begin call the task toDo List action.");
		/***/
		//----------------------20180502  记忆查询
		Act act1=new Act();
		act1=act;
		//------------------------------------20180502    记忆查询
        if(StringUtils.isNotBlank(request.getParameter("actywh"))){
        	act1.setYwh(request.getParameter("actywh"));
        }
        if(StringUtils.isNotBlank(request.getParameter("actsqr"))){
        	act1.setSqr(request.getParameter("actsqr"));
        }
        if(StringUtils.isNotBlank(request.getParameter("actdjlx"))){
        	act1.setDjlx(request.getParameter("actdjlx"));
        }
        if(StringUtils.isNotBlank(request.getParameter("acttitle"))){
        	act1.setTitle(request.getParameter("acttitle"));
        }
        String qxdm = Global.getAreaCode();
        model.addAttribute("qxdm", qxdm);
        model.addAttribute("act1", act1);
        
        User user = UserUtils.getUser();
        String office = officeService.get(user.getOffice().getParent()).getName();
        //用户类型为审核或者指定人员时,有反馈意见权限
		if(user.getUserType().equals("2") || user.getName().equals("代军") || user.getName().equals("王才旺")) {
			model.addAttribute("feedbackbj",'1');
		}
		//用户类型为柜台受理且部门为柜台受理时有预约叫号权限
		if(user.getUserType().equals("3") && office.indexOf("柜台受理") != -1) {
			model.addAttribute("orderbj",'1');
		}
        //--------------------------
         
		//--------------------------
        act.setTitle(null);
		Page<Act> page = new Page<Act>(request, response);
		if(StringUtils.isNotBlank(n) && StringUtils.isNotBlank(s)){
			page.setPageNo(Integer.parseInt(n));
			page.setPageSize(Integer.parseInt(s));
		}
		page = actTaskService.todoList(page, act);
		model.addAttribute("page", page);
		//add point for trace the claim operation issue.
		ActivitiLog.debug("end call the task toDo List action.");
		if (UserUtils.getPrincipal().isMobileLogin()){
			return renderString(response, page);
		}
		//-----------2018-11-28 GL 评价器获取人员证件号
		if (!StringUtils.isBlank(request.getParameter("tzrzjhm"))) {
			model.addAttribute("tzrzjhm", request.getParameter("tzrzjhm"));
		}
		//---------------------------------
		return "modules/act/actTaskTodoList";
	}

	/**
	 * 获取已办任务
	 * @param page
	 * @param procDefKey 流程定义标识
	 * @return
	 */
	@RequestMapping(value = "historic")
	public String historicList(Act act, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
		//----------------------20180502记忆查询
		Act act1=new Act();
		act1=act;
		//------------------------------------20180502 f   记忆查询
        if(StringUtils.isNotBlank(request.getParameter("actywh"))){
        	act1.setYwh(request.getParameter("actywh"));
        }
        if(StringUtils.isNotBlank(request.getParameter("actsqr"))){
        	act1.setSqr(request.getParameter("actsqr"));
        }
        if(StringUtils.isNotBlank(request.getParameter("actdjlx"))){
        	act1.setDjlx(request.getParameter("actdjlx"));
        }
        if(StringUtils.isNotBlank(request.getParameter("acttitle"))){
        	act1.setTitle(request.getParameter("acttitle"));
         }
         model.addAttribute("act1", act1);
		//---------------------
		Page<Act> page = new Page<Act>(request, response);
		page = actTaskService.historicList(page, act);
		model.addAttribute("page", page);
		if (UserUtils.getPrincipal().isMobileLogin()){
			return renderString(response, page);
		}
		return "modules/act/actTaskHistoricList";
	}
	
	public Page<Act> gethistoricList(Act act, HttpServletRequest request, HttpServletResponse response) throws Exception {
		Page<Act> page = new Page<Act>(request, response);
		page = actTaskService.historicList(page, act);	
		return page;
	}

	/**
	 * 获取流转历史列表
	 * @param procInsId 流程实例
	 * @param startAct 开始活动节点名称
	 * @param endAct 结束活动节点名称
	 */
	@RequestMapping(value = "histoicFlow")
	public String histoicFlow(Act act, String startAct, String endAct, Model model){
		//System.out.println("流转历史列表信息:"+ act.getProcInsId() + ";" + startAct + ";" + endAct);
		if (StringUtils.isNotBlank(act.getProcInsId())){
			List<Act> histoicFlowList = actTaskService.histoicFlowList(act.getProcInsId(), startAct, endAct);
			//System.out.println("流转历史列表信息:"+ act.getProcInsId() + ";" + startAct + ";" + endAct);
			
			List errorlst = Lists.newArrayList();
			for (Act act2 : histoicFlowList) {
				if(act2.getHistIns().getActivityName().equals("启动登记业务")){ 
					errorlst.add(act2);
				}
			} 
			histoicFlowList.removeAll(errorlst);
			model.addAttribute("histoicFlowList", histoicFlowList);
		}
		return "modules/act/actTaskHistoricFlow";
	}
	
	/**
	 * 获取流程列表
	 * @param category 流程分类
	 */
	@RequestMapping(value = "process")
	public String processList(String category, HttpServletRequest request, HttpServletResponse response, Model model) {
	    Page<Object[]> page = new Page<Object[]>(request, response);
	    page = actTaskService.processList(page, category);
		model.addAttribute("page", page);
		model.addAttribute("category", category);
		return "modules/act/actTaskProcessList";
	}
	
	/**
	 * 获取流程表单
	 * @param taskId	任务ID
	 * @param taskName	任务名称
	 * @param taskDefKey 任务环节标识
	 * @param procInsId 流程实例ID
	 * @param procDefId 流程定义ID
	 */
	@RequestMapping(value = "form")
	public String form(Act act, HttpServletRequest request, Model model){
		String isClaim = request.getParameter("isclaim");
		if(StringUtils.isNotBlank(isClaim) && "1".equals(isClaim)){
			//add point for trace the claim operation issue.
			if(ActivitiLog.isTraceDebug()){
				Task task = actTaskService.getTask(act.getTaskId());
				RegBusSlsq regBusSlsq = regBusSlsqService.getByProcInsId(task.getProcessInstanceId());
				ActivitiLog.debug("auto claim by parameter. taskId:"+act.getTaskId()+" ywh:"+regBusSlsq.getYwh());
			}
			String userId = UserUtils.getUser().getLoginName();
			actTaskService.claim(act.getTaskId(), userId);
		}
		//------------------------------------20180502 f   记忆查询
        if(StringUtils.isNotBlank(request.getParameter("actywh"))){
        	model.addAttribute("actywh", request.getParameter("actywh"));
        }
        if(StringUtils.isNotBlank(request.getParameter("actsqr"))){
        	model.addAttribute("actsqr", request.getParameter("actsqr"));
        }
        if(StringUtils.isNotBlank(request.getParameter("actdjlx"))){
        	model.addAttribute("actdjlx", request.getParameter("actdjlx"));
        }
        if(StringUtils.isNotBlank(request.getParameter("acttitle"))){
        	model.addAttribute("acttitle", request.getParameter("acttitle"));
         }
        //----------------------------------
		// 获取流程XML上的表单KEY
		String formKey = actTaskService.getFormKey(act.getProcDefId(), act.getTaskDefKey()); ///reg/bus/regBusSlsq/form
		// 获取流程实例对象
		if (act.getProcInsId() != null){
			act.setProcIns(actTaskService.getProcIns(act.getProcInsId()));
		}
		//当前setBusinessId失败时,通过act.getProcInsId()可以再补充获取一次 BusinessId = reg_bus_sqsl:id
		RegBusSlsq regBusSlsq = regBusSlsqService.getByProcInsId(act.getProcInsId());
		act.setBusinessId(regBusSlsq.getId());
		//System.out.println(ActUtils.getFormUrl(formKey, act));
		
		StringBuilder sb = new StringBuilder();
		sb.append("当前业务流程环节:"+regBusSlsq.getTaskdefkey()).
			append("当前业务小类:"+regBusSlsq.getDjxl()).append(";当前受理申请对应的流程ID:"+ regBusSlsq.getProcInsId()).
			append(";当前受理申请业务号:"+ regBusSlsq.getYwh()).
		    append(";当前登录用户信息:登录名,"+ UserUtils.getUser().getLoginName()).
			append(";当前登录用户名,"+ UserUtils.getUser().getName()).
			append(";当前登录用户IP,"+ UserUtils.getUser().getLoginIp()).
			append(";当前登录标识,"+ UserUtils.getUser().getLoginFlag());
		logger.info("【FIND_ACT_ERR·ActtaskController·save】"+sb.toString());
		
		return "redirect:" + ActUtils.getFormUrl(formKey, act,request,model);
		
//		// 传递参数到视图
//		model.addAttribute("act", act);
//		model.addAttribute("formUrl", formUrl);
//		return "modules/act/actTaskForm";
	}
	
	/**
	* @Title: formsubmit 
	* @Description: TODO(这里用一句话描述这个方法的作用) 
	* @param @param act
	* @param @param request
	* @param @param model
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws
	 */
	@RequestMapping(value = "listsubmit")
	public synchronized String listsubmit(Act act, HttpServletRequest request, Model model){
		String isClaim = request.getParameter("isclaim");
		if(StringUtils.isNotBlank(isClaim) && "1".equals(isClaim)){
			//add point for trace the claim operation issue.
			if(ActivitiLog.isTraceDebug()){
				Task task = actTaskService.getTask(act.getTaskId());
				RegBusSlsq regBusSlsq = regBusSlsqService.getByProcInsId(task.getProcessInstanceId());
				ActivitiLog.debug("auto claim by parameter. taskId:"+act.getTaskId()+" ywh:"+regBusSlsq.getYwh());
			}
			String userId = UserUtils.getUser().getLoginName();
			actTaskService.claim(act.getTaskId(), userId);
		}

		// 获取流程XML上的表单KEY
		String formKey = actTaskService.getFormKey(act.getProcDefId(), act.getTaskDefKey());
		// 获取流程实例对象
		if (act.getProcInsId() != null){
			act.setProcIns(actTaskService.getProcIns(act.getProcInsId()));
		}
		/*
		if("reg_audit".equals(act.getTaskDefKey())){
			act.setComment("初审合格");
		}else if("reg_audit2".equals(act.getTaskDefKey())){
			act.setComment("复审合格");
		}else if("reg_audit3".equals(act.getTaskDefKey())){
			act.setComment("核定通过");
		}*/
//		if(act.getListsubmit() != null){
//			model.addAttribute("Listsubmit", act.getListsubmit());
//		}
		//当前setBusinessId失败时,通过act.getProcInsId()可以再补充获取一次 BusinessId = reg_bus_sqsl:id
		RegBusSlsq regBusSlsq = regBusSlsqService.getByProcInsId(act.getProcInsId()); //流程ID获取受理任务
		act.setBusinessId(regBusSlsq.getId());
		return "redirect:" + ActUtils.getFormUrl(formKey, act,request,model);
	}

	
	/**
	 * 启动流程
	 * @param procDefKey 流程定义KEY
	 * @param businessTable 业务表表名
	 * @param businessId	业务表编号
	 */
	@RequestMapping(value = "start")
	@ResponseBody
	public String start(Act act, String table, String id, Model model) throws Exception {
		actTaskService.startProcess(act.getProcDefKey(), act.getBusinessId(), act.getBusinessTable(), act.getTitle());
		return "true";//adminPath + "/act/task";
	}

	/**
	 * 签收任务
	 * @param taskId 任务ID
	 */
	@RequestMapping(value = "claim")
	@ResponseBody
	public String claim(Act act) {
		//add point for trace the claim operation issue.
		if(ActivitiLog.isTraceDebug()){
			System.out.println(ActivitiLog.isTraceDebug());
			Task task = actTaskService.getTask(act.getTaskId());
			RegBusSlsq regBusSlsq = regBusSlsqService.getByProcInsId(task.getProcessInstanceId());
			ActivitiLog.debug("claim at actTaskTodoList ? "+act.isTracePoint()+" taskId:"+act.getTaskId()+" ywh:"+regBusSlsq.getYwh());
		}
		String userId = UserUtils.getUser().getLoginName();//ObjectUtils.toString(UserUtils.getUser().getId());
		
		//判断任务签收
		Task taskinfo = actTaskService.getTask(act.getTaskId());
		if("reg_start".equals(taskinfo.getTaskDefinitionKey())){
			//回写task表用户
			Map maptask = Maps.newHashMap();
			maptask.put("assignee",userId);
			maptask.put("taskid",taskinfo.getId());
			regBusSlsqService.updateslsqtask(maptask);
			//如果是受理环节签收,则做相关操作
			Map map = Maps.newHashMap();
			map.put("taskid", taskinfo.getId());
			map.put("procinstid", taskinfo.getProcessInstanceId());
			regBusSlsqService.updateslsqidentity(map);
		}else{
			actTaskService.claim(act.getTaskId(), userId);
		}
		return "true";//adminPath + "/act/task";
	}

	/**
	 * 完成任务
	 * @param taskId 任务ID
	 * @param procInsId 流程实例ID,如果为空,则不保存任务提交意见
	 * @param comment 任务提交意见的内容
	 * @param vars 任务流程变量,如下
	 * 		vars.keys=flag,pass
	 * 		vars.values=1,true
	 * 		vars.types=S,B  @see com.thinkgem.jeesite.modules.act.utils.PropertyType
	 */
	@RequestMapping(value = "complete")
	@ResponseBody
	public String complete(Act act) {
		//add point for trace the claim operation issue.
		ActivitiLog.debug("Call the complete action should never be executed. taskId:"+act.getTaskId());
		actTaskService.complete(act.getTaskId(), act.getProcInsId(), act.getComment(), act.getVars().getVariableMap());
		return "true";//adminPath + "/act/task";
	}
	
	/**
	 * 读取带跟踪的图片
	 */
	@RequestMapping(value = "trace/photo/{procDefId}/{execId}")
	public void tracePhoto(@PathVariable("procDefId") String procDefId, @PathVariable("execId") String execId, HttpServletResponse response) throws Exception {
		InputStream imageStream = actTaskService.tracePhoto(procDefId, execId);
		// 输出资源内容到相应对象
		byte[] b = new byte[1024];
		int len;
		while ((len = imageStream.read(b, 0, 1024)) != -1) {
			response.getOutputStream().write(b, 0, len);
		}
	}
	
	/**
	 * 输出跟踪流程信息
	 * 
	 * @param processInstanceId
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(value = "trace/info/{proInsId}")
	public List<Map<String, Object>> traceInfo(@PathVariable("proInsId") String proInsId) throws Exception {
		List<Map<String, Object>> activityInfos = actTaskService.traceProcess(proInsId);
		return activityInfos;
	}

	/**
	 * 显示流程图
	 
	@RequestMapping(value = "processPic")
	public void processPic(String procDefId, HttpServletResponse response) throws Exception {
		ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).singleResult();
		String diagramResourceName = procDef.getDiagramResourceName();
		InputStream imageStream = repositoryService.getResourceAsStream(procDef.getDeploymentId(), diagramResourceName);
		byte[] b = new byte[1024];
		int len = -1;
		while ((len = imageStream.read(b, 0, 1024)) != -1) {
			response.getOutputStream().write(b, 0, len);
		}
	}*/
	
	/**
	 * 获取跟踪信息
	 
	@RequestMapping(value = "processMap")
	public String processMap(String procDefId, String proInstId, Model model)
			throws Exception {
		List<ActivityImpl> actImpls = new ArrayList<ActivityImpl>();
		ProcessDefinition processDefinition = repositoryService
				.createProcessDefinitionQuery().processDefinitionId(procDefId)
				.singleResult();
		ProcessDefinitionImpl pdImpl = (ProcessDefinitionImpl) processDefinition;
		String processDefinitionId = pdImpl.getId();// 流程标识
		ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
				.getDeployedProcessDefinition(processDefinitionId);
		List<ActivityImpl> activitiList = def.getActivities();// 获得当前任务的所有节点
		List<String> activeActivityIds = runtimeService.getActiveActivityIds(proInstId);
		for (String activeId : activeActivityIds) {
			for (ActivityImpl activityImpl : activitiList) {
				String id = activityImpl.getId();
				if (activityImpl.isScope()) {
					if (activityImpl.getActivities().size() > 1) {
						List<ActivityImpl> subAcList = activityImpl
								.getActivities();
						for (ActivityImpl subActImpl : subAcList) {
							String subid = subActImpl.getId();
							System.out.println("subImpl:" + subid);
							if (activeId.equals(subid)) {// 获得执行到那个节点
								actImpls.add(subActImpl);
								break;
							}
						}
					}
				}
				if (activeId.equals(id)) {// 获得执行到那个节点
					actImpls.add(activityImpl);
					System.out.println(id);
				}
			}
		}
		model.addAttribute("procDefId", procDefId);
		model.addAttribute("proInstId", proInstId);
		model.addAttribute("actImpls", actImpls);
		return "modules/act/actTaskMap";
	}*/
	
	/**@RequiresPermissions("act:process:edit")
	 * 删除任务
	 * @param taskId 流程实例ID
	 * @param reason 删除原因
	 */
	@RequestMapping(value = "deleteTask")
	public String deleteTask(String taskId, String reason, RedirectAttributes redirectAttributes) {
		if (StringUtils.isBlank(reason)){
			addMessage(redirectAttributes, "请填写删除原因");
		}else{
			actTaskService.deleteTask(taskId, reason);
			addMessage(redirectAttributes, "删除任务成功,任务ID=" + taskId);
		}
		return "redirect:" + adminPath + "/act/task";
	}
	
	/**
	 * 删除任务流程实例
	 * @param procInsId 流程实例ID
	 * @param reason 删除原因
	 */
	@RequestMapping(value = "deleteProcInsByTaskList")
	public String deleteProcInsByTaskList(String procInsId, String ywh, String reason, RedirectAttributes redirectAttributes) {
		//受理申请
		RegBusSlsq regBusSlsq = regBusSlsqService.getByYwh(ywh);
		if (StringUtils.isBlank(reason)){
			addMessage(redirectAttributes, "请填写删除原因");
		}else{
			actProcessService.deleteProcIns(procInsId, reason);
			historyService.deleteHistoricProcessInstance(procInsId);
			addMessage(redirectAttributes, "删除流程实例和任务成功,任务业务号=" + ywh);
		}
		//判断如果是新增宗地信息的业务,这时需要把新增的宗地也连带删除了
		if("201".equals(regBusSlsq.getDjxl()) || "202".equals(regBusSlsq.getDjxl()) || "203".equals(regBusSlsq.getDjxl()) || 
				"204".equals(regBusSlsq.getDjxl()) || "406".equals(regBusSlsq.getDjxl()) || "407".equals(regBusSlsq.getDjxl())){
			RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
			regBusBdcqzsdjxx.setYwh(ywh);
			List<RegBusBdcqzsdjxx> findList3 = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
			int regBusBdcqzsdjxxCount = findList3.size();
			if(regBusBdcqzsdjxxCount>0){
				for(int i=0;i<regBusBdcqzsdjxxCount; i++){
					regBusBdcqzsdjxx = findList3.get(i);
					RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
					regBaseZdjbxx.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
					List<RegBaseZdjbxx> findZdList = regBaseZdjbxxService.findList(regBaseZdjbxx);
					if(findZdList.size()>0){
						regBaseZdjbxxService.delete(findZdList.get(0));
					}
				}
			}
		}
		//土地房屋查封
//		if("905".equals(regBusSlsq.getDjxl()) || "901".equals(regBusSlsq.getDjxl()) || "906".equals(regBusSlsq.getDjxl())){
//			if(StringUtils.isNotBlank(ywh)){
//				RegBusCfdj cfdj = new RegBusCfdj();
//				cfdj.setYwh(ywh);
//				List<RegBusCfdj> cflist = regBusCfdjService.findList(cfdj);
//				if(cflist.size() > 0){
//					regBusQlrService.deleteywh(ywh);
//					for(int i=0;i<cflist.size();i++){
//						cfdj =cflist.get(i);
//						regBusCfdjService.fwcfdelete(cfdj);
//						addMessage(redirectAttributes, "删除查封登记信息成功");
//						
//						RegBaseZdjbxx zdjbxx = new RegBaseZdjbxx();
//						zdjbxx.setZddm(cfdj.getBdcdyh().substring(0, 19));
//						List<RegBaseZdjbxx> findList = regBaseZdjbxxService.findList(zdjbxx);
//						if(findList.size()>0){
//							zdjbxx = findList.get(0);
//							zdjbxx.setIschafeng("0");
//							regBaseZdjbxxService.save(zdjbxx);
//						}
//						
//						RegBaseH h = new RegBaseH();
//						h.setBdcdyh(cfdj.getBdcdyh().substring(0, 19));
//						List<RegBaseH> hList = regBaseHService.findList(h);
//						if(hList.size() > 0){
//							for(int ii=0;ii<hList.size();ii++){
//								h = hList.get(ii);
//								int Ischafeng = 0;
//								Ischafeng = Integer.parseInt(h.getIschafeng()); 
//								if(Ischafeng >= 100){
//									Ischafeng = Ischafeng-1;
//									//如果小于100则说明是最后一次解封
//									if(Ischafeng < 100){
//										Ischafeng = 0;
//										h.setIschafeng(String.valueOf(Ischafeng));
//										regBaseHService.save(h);
//									}else{
//										h.setIschafeng(String.valueOf(Ischafeng));
//										regBaseHService.save(h);
//									}
//								}else{
//									Ischafeng = 0;
//									h.setIschafeng(String.valueOf(Ischafeng));
//									regBaseHService.save(h);
//								}
//							}
//						}
//						//查询使用权登记信息
//						RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
//						regBusBdcqzsdjxx.setIslogout("901");//未注销
//						regBusBdcqzsdjxx.setDbsj("ISNULL");//未登簿
//						regBusBdcqzsdjxx.setBdcdyh(cfdj.getBdcdyh());
//						regBusBdcqzsdjxx.setRights("3");
//						List<RegBusBdcqzsdjxx> djList = regBusBdcqzsdjxxService.findcfList(regBusBdcqzsdjxx);
//						if(djList.size() > 0){
//							regBusBdcqzsdjxx = djList.get(0);
//							int islogut = Integer.parseInt(regBusBdcqzsdjxx.getIslogout());
//							islogut = islogut-1;
//							if(islogut >= 100){
//								regBusBdcqzsdjxx.setIslogout(String.valueOf(islogut));
//								regBusBdcqzsdjxxService.save(regBusBdcqzsdjxx);
//							}else{
//								regBusBdcqzsdjxx.setIslogout("0");
//								regBusBdcqzsdjxxService.save(regBusBdcqzsdjxx);
//							}
//						}
//					}
//				}
//				RegBusBdcqzsdjxx djxx = new RegBusBdcqzsdjxx();
//				djxx.setYwh(ywh);
//				regBusBdcqzsdjxxService.deletezyyg(djxx);
//			}
//		}
		//权利人、义务人信息表【可能还没有添加,需要判断】
		//收件主子表【可能还没有添加,需要判断】
		//已登记信息表【可能还没有添加,需要判断】
		//各种权属表8个表【可能还没有添加,需要判断】
		regBusSlsqService.delete(regBusSlsq);
		//regBusSlsqService.deleteRelationInfo(ywh,regBusSlsq.getDjxl());
		return "redirect:" + adminPath + "/act/task";
	}
	/**
	 * 删除任务流程实例
	 * @param procInsId 流程实例ID
	 * @param reason 删除原因
	 */
	@RequestMapping(value = "deleteProcInsByTaskList1")
	@ResponseBody
	public ModelMap deleteProcInsByTaskList1(String procInsId, String ywh, String reason, RedirectAttributes redirectAttributes, HttpServletRequest request) {		
		ModelMap modelMap = new ModelMap();	
		//受理申请
		RegBusSlsq regBusSlsq = regBusSlsqService.getByYwh(ywh);
		if (StringUtils.isBlank(request.getParameter("reason"))){
			addMessage(redirectAttributes, "请填写删除原因");
		}else{
			actProcessService.deleteProcIns(procInsId, reason);
			historyService.deleteHistoricProcessInstance(procInsId);
			addMessage(redirectAttributes, "删除流程实例和任务成功,任务业务号=" + ywh);
		}
		//判断如果是新增宗地信息的业务,这时需要把新增的宗地也连带删除了
		if("201".equals(regBusSlsq.getDjxl()) || "202".equals(regBusSlsq.getDjxl()) || "203".equals(regBusSlsq.getDjxl()) || 
				"204".equals(regBusSlsq.getDjxl()) || "208".equals(regBusSlsq.getDjxl())){
			RegBusBdcqzsdjxx regBusBdcqzsdjxx = new RegBusBdcqzsdjxx();
			regBusBdcqzsdjxx.setYwh(ywh);
			List<RegBusBdcqzsdjxx> findList3 = regBusBdcqzsdjxxService.findList(regBusBdcqzsdjxx);
			int regBusBdcqzsdjxxCount = findList3.size();
			if(regBusBdcqzsdjxxCount>0){
				for(int i=0;i<regBusBdcqzsdjxxCount; i++){
					regBusBdcqzsdjxx = findList3.get(i);
					RegBaseZdjbxx regBaseZdjbxx = new RegBaseZdjbxx();
					regBaseZdjbxx.setBdcdyh(regBusBdcqzsdjxx.getBdcdyh());
					List<RegBaseZdjbxx> findZdList = regBaseZdjbxxService.findList(regBaseZdjbxx);
					if(findZdList.size()>0){
						RegBaseZdjbxx regBaseZdjbxx2 = findZdList.get(0);
						regBaseZdjbxx2.setIslogout("3");
						regBaseZdjbxx2.setIsaudit("1");
						modelMap.put("zdjbxx", regBaseZdjbxx2);
						modelMap.put("djxl", regBusSlsq.getDjxl());
						modelMap.put("chid", regBaseZdjbxx2.getChid());
						
						regBaseZdjbxxService.save(regBaseZdjbxx2);
						//新增宗地基本信息删除,只留下测绘信息
						//regBaseZdjbxxService.delete(regBaseZdjbxx2);
					}
				}
			}
		}
		   
		//权利人、义务人信息表【可能还没有添加,需要判断】
			regBusQlrService.deleteywh(ywh);
			regBusYwrService.deleteywh(ywh);
		
		//已登记信息表【可能还没有添加,需要判断】
		  
		  if(Global.isYcsl() && regBusSlsq.getDjxl().equals("302")) {
			   RegBusBdcqzsdjxx djxx = new RegBusBdcqzsdjxx();
				djxx.setYwh(ywh);
				List<RegBusBdcqzsdjxx> findList4 = regBusBdcqzsdjxxService.findList(djxx);
				if(findList4.size()>0) {
				YcslJbxx jbxx = ycslJbxxService.getbdcdyh(findList4.get(0).getBdcdyh());
				jbxx.setZt("true");
				ycslJbxxService.save(jbxx);
				}
			}
		  regBusBdcqzsdjxxService.deleteywh(ywh);
		//各种权属表8个表【可能还没有添加,需要判断】
			regBusFdcq2Service.deleteywh(ywh);
			regBusFdcq1Service.deleteywh(ywh);
			regBusJsydsyqService.deleteywh(ywh);
			regBusYgdjService.deleteywh(ywh);
			regBusCfdjService.deleteywh(ywh);
			regBusYydjService.deleteywh(ywh);
			regBusDyaqService.deleteywh(ywh);
			regBusTdsyqService.deleteywh(ywh);
			
		regBusSlsqService.delete(regBusSlsq);
		//删除受理申请中附件
		RegUtils.deletefjinfo(ywh, regBusSlsq.getFjinfo(), request);
		regBusSlsqService.deleteRelationInfo(ywh,regBusSlsq.getDjxl(),request);
		return modelMap;
	}
	
	@RequestMapping(value = "changeYWXL")
	@ResponseBody
	public ModelMap changeYWXL(HttpServletRequest request,Model model) {
		ModelMap modelMap = new ModelMap();
		String djlx=request.getParameter("djlx");	
		if(StringUtils.isNotBlank(djlx)){
		List<Dict> djlxTemplist= DictUtils.getDictLabeldlxl(""+(Integer.parseInt(djlx.substring(0, 1))+1),"reg_bus_djxl", " ");
		 modelMap.put("ywxl", djlxTemplist);
		}	
	    return modelMap;
	}
	
	/**
	 * 一窗受理,删除任务流程实例
	 * @param procInsId 流程实例ID
	 * @param reason 删除原因
	 */
	public String deleteProcInsByTaskToYcsl(String procInsId, String ywh, String reason) throws Exception{		
		String message = "";
		try{
			//受理申请
			RegBusSlsq regBusSlsq = regBusSlsqService.getByYwh(ywh);
			if (StringUtils.isBlank(reason)){
				message =  "请填写删除原因";
			}else{
				//删除流程
				actProcessService.deleteProcIns(procInsId, reason);
				historyService.deleteHistoricProcessInstance(procInsId);
				message = "删除流程实例和任务成功,任务业务号=" + ywh;
			}

			//权利人、义务人信息表【可能还没有添加,需要判断】
			//收件主子表【可能还没有添加,需要判断】
			//已登记信息表【可能还没有添加,需要判断】
			//各种权属表8个表【可能还没有添加,需要判断】
			regBusSlsqService.delete(regBusSlsq);
		}catch(Exception e){
			e.printStackTrace();
			message = "删除任务出错,任务业务号=" + ywh;
		}
		return message;
	}
}