<!-- CXF 配置 -->java <servlet> web <servlet-name>CXFServlet</servlet-name> spring <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> apache <load-on-startup>2</load-on-startup> json </servlet>app <servlet-mapping> dom <servlet-name>CXFServlet</servlet-name> eclipse <url-pattern>/ws/*</url-pattern> ide </servlet-mapping>工具 |
package com.plsg.ws.cxftest; import javax.jws.WebParam; import javax.jws.WebResult; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.jws.soap.SOAPBinding.Style; import net.sf.json.JSONObject; /** *CxfService *@author MLY *@date 2017年2月28日 上午9:44:10 */ @WebService @SOAPBinding(style=Style.RPC) public interface CxfService {
public @WebResult(name="cxfList") JSONObject leaderApproval(@WebParam(name="appPoliceno",targetNamespace="http://cxftest.ws.plsg.com/") String appPoliceno, @WebParam(name="nextUserPoliceno",targetNamespace="http://cxftest.ws.plsg.com/") String nextUserPoliceno, @WebParam(name="appState",targetNamespace="http://cxftest.ws.plsg.com/") Integer appState, @WebParam(name="suggestion",targetNamespace="http://cxftest.ws.plsg.com/") String suggestion, @WebParam(name="bizType",targetNamespace="http://cxftest.ws.plsg.com/") Integer bizType, @WebParam(name="bizId",targetNamespace="http://cxftest.ws.plsg.com/") String bizId, @WebParam(name="isMeeting",targetNamespace="http://cxftest.ws.plsg.com/") String isMeeting, @WebParam(name="attachmentJson",targetNamespace="http://cxftest.ws.plsg.com/") String attachmentJson);
} |
package com.plsg.ws.cxftest;
import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map;
import net.sf.json.JSONArray; import net.sf.json.JSONObject;
import org.activiti.engine.HistoryService; import org.activiti.engine.RepositoryService; import org.activiti.engine.RuntimeService; import org.activiti.engine.TaskService; import org.activiti.engine.history.HistoricActivityInstance; import org.activiti.engine.task.IdentityLink; import org.activiti.engine.task.Task; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.apache.shiro.subject.Subject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; import com.opsyspower.framework.basis.authentication.domain.ShiroUser; import com.opsyspower.framework.basis.userdept.domain.User; import com.opsyspower.framework.basis.userdept.service.AccountService; import com.opsyspower.framework.basis.userdept.service.UserService; import com.opsyspower.framework.workflow.business.domain.WfBiz; import com.opsyspower.framework.workflow.ex.service.CustomTaskService; import com.opsyspower.framework.workflow.model.ApproveInfo; import com.opsyspower.framework.workflow.model.TaskNotify; import com.opsyspower.framework.workflow.service.ActivitiService; import com.opsyspower.framework.workflow.service.HistoricTaskService; import com.opsyspower.framework.workflow.service.WorkflowService; import com.plsg.cars.domian.CarsRepair; import com.plsg.cars.service.CarsRepairService; import com.plsg.constract.controller.ConstractWorkFlowController; import com.plsg.constract.domian.Constract; import com.plsg.constract.service.ConstractService; import com.plsg.gyzcgl.domain.GyBudget; import com.plsg.gyzcgl.domain.GyTransfer; import com.plsg.gyzcgl.service.GyBudgetService; import com.plsg.gyzcgl.service.GyTransferService; import com.plsg.jwbzsx.controller.FangwuWorkFlowController; import com.plsg.jwbzsx.controller.GuoyouWorkFlowController; import com.plsg.jwbzsx.controller.JingfeiWorkFlowController; import com.plsg.jwbzsx.controller.PoliceApplyWorkFlowController; import com.plsg.jwbzsx.domain.GoodsBill; import com.plsg.jwbzsx.domain.GuoyouCount; import com.plsg.jwbzsx.domain.PoliceApply; import com.plsg.jwbzsx.service.DemandApplyService; import com.plsg.jwbzsx.service.GoodsBillService; import com.plsg.jwbzsx.service.GuoyouCountService; import com.plsg.jwbzsx.service.PoliceApplyService; import com.plsg.ws.domin.MeetAttachment; import com.plsg.ws.service.MeetAttachmentService;
/** * CxfServiceImpl */ @Controller public class CxfServiceImpl implements CxfService {
@Autowired TaskService taskService;
@Autowired PoliceApplyService policeApplyService;
@Autowired DemandApplyService demandApplyService;
@Autowired CarsRepairService carsRepairService;
@Autowired ConstractService constractService;
@Autowired protected WorkflowService workflowService;
@Autowired private ActivitiService activitiService;
@Autowired private UserService userService;
@Autowired PoliceApplyService pas;
@Autowired(required = false) private HistoricTaskService historicTaskService;
@Autowired(required = false) private RepositoryService repositoryService;
@Autowired(required = false) private RuntimeService runtimeService;
@Autowired(required = false) private HistoryService historyService; @Autowired(required = false) private CustomTaskService customTaskService; @Autowired(required = false) private AccountService accountService; @Autowired @Qualifier("customTaskService") private CustomTaskService customService; @Autowired GoodsBillService gb; @Autowired private GyBudgetService bs; @Autowired GuoyouCountService gcs; @Autowired GyTransferService gts; @Autowired MeetAttachmentService mas;
@Override public JSONObject leaderApproval(String appPoliceno,String nextUserPoliceno, Integer appState, String suggestion, Integer bizType, String bizId, String isMeeting,String attachmentJson) { System.out.println("接收到的參數爲:appPoliceno"+appPoliceno+"||nextUserPoliceno"+nextUserPoliceno+"||appState"+appState+"||suggestion"+suggestion+"||bizType"+ bizType+"||bizId"+bizId+"||isMeeting"+isMeeting);
Map<String,String> map = new HashMap<String, String>(); map.put("result", "success"); map.put("resultInfo", "同步成功"); JSONObject result = JSONObject.fromObject(map); try { /* 獲取任務id */ String taskId = policeApplyService.getTaskIdByid(bizId); /* 根據警號查詢userId */ String userId = policeApplyService.getallUserIdBySimpleName(appPoliceno);
String nextuserIds = ""; String[] nextUserPolicenos=nextUserPoliceno.split(","); for(int i=0,len=nextUserPolicenos.length;i<len;i++){ String nextUserPolicenoSingle = nextUserPolicenos[i].toString(); String nextuserId = policeApplyService.getallUserIdBySimpleName(nextUserPolicenoSingle); nextuserIds += nextuserId+","; }
/* 簽收 */ taskService.claim(taskId, userId); User user = userService.getById(userId); System.out.println("用戶信息:"+user.getUserName());
/*保存上會附件*/ if(StringUtils.isNotBlank(attachmentJson)){ this.saveAttachment(bizId,attachmentJson,user); }
/* 封裝審批信息 */ ApproveInfo info = new ApproveInfo(); boolean flag = true; if(appState==0){ flag = false; } info.setAgree(flag); info.setNotifyNext(false); info.setOpinion(suggestion); info.setTaskId(taskId); info.setSelectUserIds(nextuserIds); /* 根據申請的類型獲取對應的清單數據,進行封裝 */ if (bizType == 1) {//採購項目 PoliceApply policeApply = policeApplyService.findById(bizId); doApprove4PoliceApply(policeApply, info,isMeeting); } else if (bizType == 2) {//基建工程 PoliceApply policeApply = policeApplyService.findById(bizId); doApprove4Fangwu(policeApply, info,isMeeting); } else if (bizType == 3) {//國有資產 PoliceApply policeApply = policeApplyService.findById(bizId); doApprove4Guoyou(policeApply, info); } else if (bizType == 4) {//經費申請 PoliceApply policeApply = policeApplyService.findById(bizId); doApprove4Jingfei(policeApply, info); } else if (bizType == 5) {//合同管理 Constract constract = constractService.getConstractsById(bizId); doApprove4Constract(constract, info,isMeeting); } else if (bizType == 6) {//車輛維修申請 CarsRepair carsRepair = carsRepairService.findById(bizId); doApprove4CarsRepair(carsRepair, info,user); }
} catch (Exception e) { map.put("result", "fault"); map.put("resultInfo", e.getMessage()); result = JSONObject.fromObject(map); e.printStackTrace(); }
return result; } /** * 保存上會附件的方法 * @param bizId 業務id * @param attachmentJson 附件json串 * @param user */ private void saveAttachment(String bizId, String attachmentJson, User user) { try { /*1.解析json字符串*/ JSONArray js = JSONArray.fromObject(attachmentJson); Object[] array = js.toArray(); for (Object object : array) { JSONObject jb = JSONObject.fromObject(object); /*2.封裝MeetAttachment對象*/ MeetAttachment ma = new MeetAttachment(); ma.setAttachmentName(jb.get("attachmentName").toString()); ma.setAttachmentUrl(jb.get("attachmentUrl").toString()); ma.setBizId(bizId); ma.setSaveDate(new Date()); ma.setOperator(user.getUserName()); /*3.保存*/ mas.saveMeetAttachment(ma); } } catch (Exception e) { e.printStackTrace(); } } /*TODO####################################################################################*/ /** * 車輛維修申請 * @param t * @param info * @param user * @return */ protected TaskNotify doApprove4CarsRepair(CarsRepair t, ApproveInfo info,User user) { Task task = workflowService.getTaskById(info.getTaskId());
String taskDefKey = task.getTaskDefinitionKey();
System.out.println("taskDefKey===" + taskDefKey);
if (taskDefKey.equals("jldps")) { t.setStatus(2); }
if (info.getProcInstId() == null) { info.setProcInstId(task.getProcessInstanceId()); } if ("李苑青".equals(user.getUserName())) { info.setSelectUserIds("40289e34574a708f01574a7e3b770003"); } Map<String, Object> vars = new HashMap<String, Object>(); return activitiService.finishTaskWithWfBiz(t, info, vars, getWfBiz()); }
protected WfBiz getWfBiz() { // TODO 自動生成的方法存根 return null; } /*TODO####################################################################################*/ /** * 採購項目 * @param t * @param info * @param isMeeting * @return */ protected TaskNotify doApprove4PoliceApply(PoliceApply t, ApproveInfo info, String isMeeting) { Task task = workflowService.getTaskById(info.getTaskId()); if(info.getProcInstId()==null){ info.setProcInstId(task.getProcessInstanceId()); } String taskDefKey = task.getTaskDefinitionKey();
String tuihui = null;
boolean islast=false;
//判斷審批是否贊成,不一樣意且是退回給第一個節點,設置status爲0,可編輯 if(!info.isAgree() && !"zhinengzu".equals(taskDefKey)&&!"zhinengzuld".equals(taskDefKey)&&!"shild".equals(taskDefKey)){ //pas.updateStatus(0, t.getId()); //退回到起點,所有清空 t.setAppAgree(0); t.setAppUser(""); t.setRuPurchase(""); t.setPurchase(""); t.setStatus(0); }else{ if(t.getStatus()==0){//給第一次辦理設置時間 SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd"); String nowdate = dateFormater.format(new Date()); try { t.setApplyDate(dateFormater.parse(nowdate)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } //送審狀態 t.setStatus(1); } }
Map<String, Object> vars = new HashMap<String,Object>(); if("zhinengzu".equals(taskDefKey)||"zhinengzuld".equals(taskDefKey)){
List<String> list=new ArrayList<String>(); String newstr=null; if(islast){//最後一個會籤審批 String [] userzu = t.getAppUser().split(","); boolean flag; for(int i=0;i<userzu.length;i++){ flag = false; for(int j=0;j<list.size();j++){ if(userzu[i].equals(list.get(j))){ flag = true; break; } } if(!flag){ list.add(userzu[i]); if(newstr != null){ newstr = newstr+","+userzu[i]; }else{ newstr = userzu[i]; } } } if("zhinengzuld".equals(taskDefKey)){ info.setSelectUserIds(pas.getuserIdByrolecode("sld_shr")); } } vars.put("multiAssignees", list); if(newstr != null &&"zhinengzu".equals(taskDefKey)){ info.setSelectUserIds(newstr); } }else if (info != null && StringUtils.isNotEmpty(info.getSelectUserIds())) { List<String> list=new ArrayList<String>(); String[] userIds = info.getSelectUserIds().split(","); for (int i = 0; i < userIds.length; i++) { list.add(userIds[i]); } runtimeService.setVariable(task.getProcessInstanceId(), PoliceApplyWorkFlowController.nextUserIss, info.getSelectUserIds());
vars.put("multiAssignees", list); }
if(tuihui !=null){ info.setSelectUserIds(tuihui); } if("fenfaren".equals(taskDefKey) && (StringUtils.isEmpty(info.getSelectUserIds()) || info.getSelectUserIds()=="undefined")){ List<String> list2 = pas.getallUserIdByrolecode("znz_shr"); if(list2.size()>0){ String selectUserIds=null; for (String string : list2) { if(selectUserIds==null){ selectUserIds = string+","; }else{ selectUserIds = selectUserIds+string+","; } } info.setSelectUserIds(selectUserIds); vars.put("multiAssignees", list2); } } if("fenfaren".equals(taskDefKey)){ t.setAppAgree(0); t.setAppUser(""); t.setRuPurchase(""); t.setPurchase(""); }
//等於2不上會,流程直接結束 if(t.getAppAgree()!=2 && "daishanghui".equals(taskDefKey) && info.isAgree() || "Y".equals(isMeeting)){ vars.put("isShanghui", true); } if(t.getAppAgree()==2 && "daishanghui".equals(taskDefKey) && info.isAgree() || "N".equals(isMeeting)){ vars.put("isShanghui", false); t.setStatus(2); } if(!info.isAgree() && "daishanghui".equals(taskDefKey)){ vars.put("isShanghui", false); } //流程結束設置Status狀態爲2 if("usertask10".equals(taskDefKey) && info.isAgree()){ t.setStatus(2); }
TaskNotify tn =activitiService.finishTaskWithWfBiz(t, info, vars, getWfBiz()); // 將下一步用戶id集合存到nextUserIss變量中,供催辦使用 ---start List<HistoricActivityInstance> hiActivityInsts = historyService .createHistoricActivityInstanceQuery() .processInstanceId(task.getProcessInstanceId()).unfinished() .orderByHistoricActivityInstanceStartTime().asc().list(); if(hiActivityInsts.size()>0){ List<IdentityLink> participants = null; String userIds=""; for (HistoricActivityInstance hiActivityInst : hiActivityInsts) { participants = customTaskService .getIdentityLinksForTask(hiActivityInst .getTaskId()); for (IdentityLink participant : participants) { User user = accountService.getUserById(participant.getUserId()); userIds+=user.getId()+","; }
} userIds=userIds.length()>1?userIds.substring(0, userIds.length()-1):userIds; runtimeService.setVariable(task.getProcessInstanceId(), PoliceApplyWorkFlowController.nextUserIss,userIds);
} // 將下一步用戶id集合存到nextUserIss變量中,供催辦使用 ---end return tn; } /** * 獲取當前用戶 * * @return */ private User getCurrentUser() { Subject subject = SecurityUtils.getSubject(); ShiroUser shiroUser = (ShiroUser) subject.getSession().getAttribute( "shiroUser"); if (shiroUser != null) { User user = accountService.getUserById(shiroUser.getId()); return user; } else { return null; } } /*TODO####################################################################################*/ /** * 基建工程 * @param model * @param t * @param info * @param isMeeting * @return */ protected TaskNotify doApprove4Fangwu(PoliceApply t, ApproveInfo info, String isMeeting) { Task task = workflowService.getTaskById(info.getTaskId()); if(info.getProcInstId()==null){ info.setProcInstId(task.getProcessInstanceId()); } String taskDefKey = task.getTaskDefinitionKey();
String tuihui = null;
boolean islast=false;
//判斷審批是否贊成,不一樣意且是退回給第一個節點,設置status爲0,可編輯 if(!info.isAgree() && !"zhinengzu".equals(taskDefKey)&&!"zhinengzuld".equals(taskDefKey)&&!"shild".equals(taskDefKey)){ //pas.updateStatus(0, t.getId()); //退回到起點,所有清空 t.setAppAgree(0); t.setAppUser(""); t.setRuPurchase(""); t.setPurchase(""); t.setStatus(0); }else{ if(t.getStatus()==0){//給第一次辦理設置時間 SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd"); String nowdate = dateFormater.format(new Date()); try { t.setApplyDate(dateFormater.parse(nowdate)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } //送審狀態 t.setStatus(1); } }
Map<String, Object> vars = new HashMap<String,Object>(); if("zhinengzu".equals(taskDefKey)||"zhinengzuld".equals(taskDefKey)){
List<String> list=new ArrayList<String>(); String newstr=null; if(islast){//最後一個會籤審批 String [] userzu = t.getAppUser().split(","); boolean flag; for(int i=0;i<userzu.length;i++){ flag = false; for(int j=0;j<list.size();j++){ if(userzu[i].equals(list.get(j))){ flag = true; break; } } if(!flag){ list.add(userzu[i]); if(newstr != null){ newstr = newstr+","+userzu[i]; }else{ newstr = userzu[i]; } } } if("zhinengzuld".equals(taskDefKey)){ info.setSelectUserIds(pas.getuserIdByrolecode("sld_shr")); } } vars.put("multiAssignees", list); if(newstr != null &&"zhinengzu".equals(taskDefKey)){ info.setSelectUserIds(newstr); } }else if (info != null && StringUtils.isNotEmpty(info.getSelectUserIds())) { List<String> list=new ArrayList<String>(); String[] userIds = info.getSelectUserIds().split(","); for (int i = 0; i < userIds.length; i++) { list.add(userIds[i]); } runtimeService.setVariable(task.getProcessInstanceId(), FangwuWorkFlowController.nextUserIss, info.getSelectUserIds());
vars.put("multiAssignees", list); }
if(tuihui !=null){ info.setSelectUserIds(tuihui); } if("fenfaren".equals(taskDefKey) && (StringUtils.isEmpty(info.getSelectUserIds()) || info.getSelectUserIds()=="undefined")){ List<String> list2 = pas.getallUserIdByrolecode("znz_shr"); if(list2.size()>0){ String selectUserIds=null; for (String string : list2) { if(selectUserIds==null){ selectUserIds = string+","; }else{ selectUserIds = selectUserIds+string+","; } } info.setSelectUserIds(selectUserIds); vars.put("multiAssignees", list2); } } //在分管財務審批人時,根據金額結束流程 if("usertask7".equals(taskDefKey)){ if(t.getApplyMoney().compareTo(BigDecimal.valueOf(100000)) >=0){ vars.put("applyMoney", true); }else{//流程結束 vars.put("applyMoney", false); t.setStatus(2); }
} if("fenfaren".equals(taskDefKey)){ t.setAppAgree(0); t.setAppUser(""); t.setRuPurchase(""); t.setPurchase(""); } //等於2不上會,流程直接結束 if(t.getAppAgree()!=2 && "daishanghui".equals(taskDefKey) && info.isAgree() || "Y".equals(isMeeting)){ vars.put("isShanghui", true); } if(t.getAppAgree()==2 && "daishanghui".equals(taskDefKey) && info.isAgree() || "N".equals(isMeeting)){ vars.put("isShanghui", false); t.setStatus(2); } if(!info.isAgree() && "daishanghui".equals(taskDefKey)){ vars.put("isShanghui", false); } //流程結束設置Status狀態爲2 if("usertask9".equals(taskDefKey) && info.isAgree()){ t.setStatus(2); } TaskNotify tn =activitiService.finishTaskWithWfBiz(t, info, vars, getWfBiz()); // 將下一步用戶id集合存到nextUserIss變量中,供催辦使用 ---start List<HistoricActivityInstance> hiActivityInsts = historyService .createHistoricActivityInstanceQuery() .processInstanceId(task.getProcessInstanceId()).unfinished() .orderByHistoricActivityInstanceStartTime().asc().list(); if(hiActivityInsts.size()>0){ List<IdentityLink> participants = null; String userIds=""; for (HistoricActivityInstance hiActivityInst : hiActivityInsts) { participants = customTaskService .getIdentityLinksForTask(hiActivityInst .getTaskId()); for (IdentityLink participant : participants) { User user = accountService.getUserById(participant.getUserId()); userIds+=user.getId()+","; }
} userIds=userIds.length()>1?userIds.substring(0, userIds.length()-1):userIds; runtimeService.setVariable(task.getProcessInstanceId(), FangwuWorkFlowController.nextUserIss,userIds);
} // 將下一步用戶id集合存到nextUserIss變量中,供催辦使用 ---end return tn;
} /*TODO####################################################################################*/ /** * 經費申請 * @param model * @param t * @param info * @return */ protected TaskNotify doApprove4Jingfei(PoliceApply t, ApproveInfo info) { Task task = workflowService.getTaskById(info.getTaskId()); if(info.getProcInstId()==null){ info.setProcInstId(task.getProcessInstanceId()); } String taskDefKey = task.getTaskDefinitionKey();
String tuihui = null;
boolean islast=false;
//判斷審批是否贊成,不一樣意且是退回給第一個節點,設置status爲0,可編輯 if(!info.isAgree() && !"zhinengzu".equals(taskDefKey)&&!"zhinengzuld".equals(taskDefKey)&&!"shild".equals(taskDefKey)){ //pas.updateStatus(0, t.getId()); //退回到起點,所有清空 t.setAppAgree(0); t.setAppUser(""); t.setRuPurchase(""); t.setPurchase(""); t.setStatus(0); }else{ if(t.getStatus()==0){//給第一次辦理設置時間 SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd"); String nowdate = dateFormater.format(new Date()); try { t.setApplyDate(dateFormater.parse(nowdate)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } //送審狀態 t.setStatus(1); } }
Map<String, Object> vars = new HashMap<String,Object>(); if("zhinengzu".equals(taskDefKey)||"zhinengzuld".equals(taskDefKey)){
List<String> list=new ArrayList<String>(); String newstr=null; if(islast){//最後一個會籤審批 String [] userzu = t.getAppUser().split(","); boolean flag; for(int i=0;i<userzu.length;i++){ flag = false; for(int j=0;j<list.size();j++){ if(userzu[i].equals(list.get(j))){ flag = true; break; } } if(!flag){ list.add(userzu[i]); if(newstr != null){ newstr = newstr+","+userzu[i]; }else{ newstr = userzu[i]; } } } if("zhinengzuld".equals(taskDefKey)){ info.setSelectUserIds(pas.getuserIdByrolecode("sld_shr")); } } vars.put("multiAssignees", list); if(newstr != null &&"zhinengzu".equals(taskDefKey)){ info.setSelectUserIds(newstr); } }else if (info != null && StringUtils.isNotEmpty(info.getSelectUserIds())) { List<String> list=new ArrayList<String>(); String[] userIds = info.getSelectUserIds().split(","); for (int i = 0; i < userIds.length; i++) { list.add(userIds[i]); } runtimeService.setVariable(task.getProcessInstanceId(), JingfeiWorkFlowController.nextUserIss, info.getSelectUserIds());
vars.put("multiAssignees", list); }
if(tuihui !=null){ info.setSelectUserIds(tuihui); } if("fenfaren".equals(taskDefKey) && (StringUtils.isEmpty(info.getSelectUserIds()) || info.getSelectUserIds()=="undefined")){ List<String> list2 = pas.getallUserIdByrolecode("znz_shr"); if(list2.size()>0){ String selectUserIds=null; for (String string : list2) { if(selectUserIds==null){ selectUserIds = string+","; }else{ selectUserIds = selectUserIds+string+","; } } info.setSelectUserIds(selectUserIds); vars.put("multiAssignees", list2); } }
//分管單位,分管財務是否同一人 //等於2同一人,流程直接結束 if(t.getAppAgree()!=2 && "usertask9".equals(taskDefKey) && info.isAgree()){ vars.put("notOnly", false); } if(t.getAppAgree()==2 && "usertask9".equals(taskDefKey) && info.isAgree()){ vars.put("notOnly", true); t.setStatus(2); } if(!info.isAgree() && "usertask9".equals(taskDefKey)){ vars.put("notOnly", false); } //流程結束設置Status狀態爲2 if("usertask10".equals(taskDefKey) && info.isAgree()){ t.setStatus(2); }
TaskNotify tn =activitiService.finishTaskWithWfBiz(t, info, vars, getWfBiz()); // 將下一步用戶id集合存到nextUserIss變量中,供催辦使用 ---start List<HistoricActivityInstance> hiActivityInsts = historyService .createHistoricActivityInstanceQuery() .processInstanceId(task.getProcessInstanceId()).unfinished() .orderByHistoricActivityInstanceStartTime().asc().list(); if(hiActivityInsts.size()>0){ List<IdentityLink> participants = null; String userIds=""; for (HistoricActivityInstance hiActivityInst : hiActivityInsts) { participants = customTaskService .getIdentityLinksForTask(hiActivityInst .getTaskId()); for (IdentityLink participant : participants) { User user = accountService.getUserById(participant.getUserId()); userIds+=user.getId()+","; }
} userIds=userIds.length()>1?userIds.substring(0, userIds.length()-1):userIds; runtimeService.setVariable(task.getProcessInstanceId(), JingfeiWorkFlowController.nextUserIss,userIds);
} // 將下一步用戶id集合存到nextUserIss變量中,供催辦使用 ---end return tn; } /*TODO####################################################################################*/ /** * 國有資產 * @param model * @param t * @param info * @return */ protected TaskNotify doApprove4Guoyou(PoliceApply t, ApproveInfo info) { Task task = workflowService.getTaskById(info.getTaskId()); if(info.getProcInstId()==null){ info.setProcInstId(task.getProcessInstanceId()); } String taskDefKey = task.getTaskDefinitionKey();
String tuihui = null;
boolean islast=false;
//判斷審批是否贊成,不一樣意且是退回給第一個節點,設置status爲0,可編輯 if(!info.isAgree() && !"zhinengzu".equals(taskDefKey)&&!"zhinengzuld".equals(taskDefKey)&&!"shild".equals(taskDefKey)){ //pas.updateStatus(0, t.getId()); //退回到起點,所有清空 t.setAppAgree(0); t.setAppUser(""); t.setRuPurchase(""); t.setPurchase(""); t.setStatus(0); }else{ if(t.getStatus()==0){//給第一次辦理設置時間 SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd"); String nowdate = dateFormater.format(new Date()); try { t.setApplyDate(dateFormater.parse(nowdate)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } //送審狀態 t.setStatus(1); } }
Map<String, Object> vars = new HashMap<String,Object>(); if("zhinengzu".equals(taskDefKey)||"zhinengzuld".equals(taskDefKey)){
List<String> list=new ArrayList<String>(); String newstr=null; if(islast){//最後一個會籤審批 String [] userzu = t.getAppUser().split(","); boolean flag; for(int i=0;i<userzu.length;i++){ flag = false; for(int j=0;j<list.size();j++){ if(userzu[i].equals(list.get(j))){ flag = true; break; } } if(!flag){ list.add(userzu[i]); if(newstr != null){ newstr = newstr+","+userzu[i]; }else{ newstr = userzu[i]; } } } if("zhinengzuld".equals(taskDefKey)){ info.setSelectUserIds(pas.getuserIdByrolecode("sld_shr")); } } vars.put("multiAssignees", list); if(newstr != null &&"zhinengzu".equals(taskDefKey)){ info.setSelectUserIds(newstr); } }else if (info != null && StringUtils.isNotEmpty(info.getSelectUserIds())) { List<String> list=new ArrayList<String>(); String[] userIds = info.getSelectUserIds().split(","); for (int i = 0; i < userIds.length; i++) { list.add(userIds[i]); } runtimeService.setVariable(task.getProcessInstanceId(), GuoyouWorkFlowController.nextUserIss, info.getSelectUserIds());
vars.put("multiAssignees", list); }
if(tuihui !=null){ info.setSelectUserIds(tuihui); } if("fenfaren".equals(taskDefKey) && (StringUtils.isEmpty(info.getSelectUserIds()) || info.getSelectUserIds()=="undefined")){ List<String> list2 = pas.getallUserIdByrolecode("znz_shr"); if(list2.size()>0){ String selectUserIds=null; for (String string : list2) { if(selectUserIds==null){ selectUserIds = string+","; }else{ selectUserIds = selectUserIds+string+","; } } info.setSelectUserIds(selectUserIds); vars.put("multiAssignees", list2); } } if("fenfaren".equals(taskDefKey)){ t.setAppAgree(0); t.setAppUser(""); t.setRuPurchase(""); t.setPurchase(""); } //等於2不送局領導,流程調撥直接結束 if(t.getAppAgree()!=2 && "shild".equals(taskDefKey) && info.isAgree()){ vars.put("shangbao", true); } if(t.getAppAgree()==2 && "shild".equals(taskDefKey) && info.isAgree()){ vars.put("shangbao", false); t.setStatus(2); //流程結束,保存新增的數據到國有資產卡片數據當中 this.saveGy(t.getApplyNo()); //更新國有資產卡片數據中的所屬部門 this.updateGyDept(t.getApplyNo()); } //室領導不一樣意,刪除調撥,同時改變國有資產卡片數據中的狀態 if(!info.isAgree() && "shild".equals(taskDefKey)){ vars.put("shangbao", false); this.deleteDb(t.getApplyNo()); } //職能組領導不一樣意,刪除調撥 if(!info.isAgree() && "zhinengzuld".equals(taskDefKey)){ this.deleteDb(t.getApplyNo()); } //流程結束設置Status狀態爲2 if("usertask9".equals(taskDefKey) && info.isAgree()){ t.setStatus(2); //分管單位領導贊成, //流程結束,保存新增的數據到國有資產卡片數據當中 this.saveGy(t.getApplyNo()); //更新國有資產卡片數據中的所屬部門 this.updateGyDept(t.getApplyNo()); } if("usertask9".equals(taskDefKey) && !info.isAgree()){ //分管單位領導不一樣意,駁回至起點,刪除已調撥物資 t.setStatus(0); this.deleteDb(t.getApplyNo()); } TaskNotify tn =activitiService.finishTaskWithWfBiz(t, info, vars, getWfBiz()); // 將下一步用戶id集合存到nextUserIss變量中,供催辦使用 ---start List<HistoricActivityInstance> hiActivityInsts = historyService .createHistoricActivityInstanceQuery() .processInstanceId(task.getProcessInstanceId()).unfinished() .orderByHistoricActivityInstanceStartTime().asc().list(); if(hiActivityInsts.size()>0){ List<IdentityLink> participants = null; String userIds=""; for (HistoricActivityInstance hiActivityInst : hiActivityInsts) { participants = customTaskService .getIdentityLinksForTask(hiActivityInst .getTaskId()); for (IdentityLink participant : participants) { User user = accountService.getUserById(participant.getUserId()); userIds+=user.getId()+","; }
} userIds=userIds.length()>1?userIds.substring(0, userIds.length()-1):userIds; runtimeService.setVariable(task.getProcessInstanceId(), GuoyouWorkFlowController.nextUserIss,userIds);
} // 將下一步用戶id集合存到nextUserIss變量中,供催辦使用 ---end return tn; }
/*TODO####################################################################################*/ /** * 合同管理 * @param model * @param t * @param info * @param isMeeting * @return */ protected TaskNotify doApprove4Constract(Constract t, ApproveInfo info, String isMeeting) {
Task task = workflowService.getTaskById(info.getTaskId()); if(info.getProcInstId()==null){ info.setProcInstId(task.getProcessInstanceId()); } String taskDefKey = task.getTaskDefinitionKey(); Map<String, Object> vars = new HashMap<String, Object>();
t.setStatus(1);
try { t.setReceiveDate(new Date()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if(!info.isAgree()){ t.setStatus(0); t.setAppAgree(0); }
//在分管領導審批人時,根據金額結束流程 if("usertask4".equals(taskDefKey)){ if(t.getConstractMoney() <100000){//流程結束 vars.put("money", true); //設置申請單據爲合同完結狀態5 if(t.getPoliceapply()!=null && !("").equals(t.getPoliceapply().getId())){ //PoliceApply p = pas.getById(t.getPoliceapply().getId()); //p.setStatus(5); pas.updateStatus(5, t.getPoliceapply().getId()); //pas.save(p); } t.setStatus(2); }else{ vars.put("money", false); }
} //在分管財務領導審批人時,根據金額結束流程 if("usertask5".equals(taskDefKey)){ if(t.getConstractMoney()<1000000 && t.getConstractMoney()>=100000){ vars.put("money", true); //設置申請單據爲合同完結狀態5 if(t.getPoliceapply()!=null && !("").equals(t.getPoliceapply().getId())){ pas.updateStatus(5, t.getPoliceapply().getId()); } t.setStatus(2); }else{//流程結束 vars.put("money", false); }
}
//等於2不上會,流程直接結束 if("usertask6".equals(taskDefKey) && t.getAppAgree()!=2 && info.isAgree() || "Y".equals(isMeeting)){ vars.put("isShanghui", true); } if("usertask6".equals(taskDefKey) && t.getAppAgree()==2 && info.isAgree() || "N".equals(isMeeting)){ vars.put("isShanghui", false); //設置申請單據爲合同完結狀態5 if(t.getPoliceapply()!=null && !("").equals(t.getPoliceapply().getId())){ pas.updateStatus(5, t.getPoliceapply().getId()); } t.setStatus(2); }
//流程結束設置Status狀態爲2 if("usertask".equals(taskDefKey) && info.isAgree()){ //設置申請單據爲合同完結狀態5 if(t.getPoliceapply()!=null && !("").equals(t.getPoliceapply().getId())){ pas.updateStatus(5, t.getPoliceapply().getId()); t.setStatus(2); } }
//vars.put("money", t.getConstractMoney()); runtimeService.setVariable(task.getProcessInstanceId(), ConstractWorkFlowController.nextUserIss, info.getSelectUserIds());
return activitiService.finishTaskWithWfBiz(t, info, vars, getWfBiz()); }
//流程結束,把新增的保存到國有資產卡片數據中,同時保存國有資產統計數據 public void saveGy(String applyno){ //根據申請單號 查詢 List<GoodsBill> goodsBills = gb.findallByApplyNo(applyno); for (GoodsBill jb : goodsBills) { if(jb.getXzQuantity() != null && jb.getXzQuantity() > 0){ for(int k=0; k<jb.getXzQuantity();k++){ GyBudget gyBudget = new GyBudget(); gyBudget.setCardId(this.getCardId()); gyBudget.setAssetName(jb.getName()); gyBudget.setAssetSortCode(jb.getAssetSortCode()); gyBudget.setDept(jb.getDept()); gyBudget.setNewDept(jb.getDept()); gyBudget.setDeptId("0"); String idsrt= gyBudget.getCardId(); String ismd5=DigestUtils.md5Hex(idsrt); gyBudget.setId(ismd5); SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); String date =sdf.format(new Date()); gyBudget.setGyBudgetYear(date); bs.savegb(gyBudget); }
} } /*保存國有資產統計數據*/ //查詢審批狀態爲2的國有資產數據 PoliceApply policeApply = pas.findByApplyNo(applyno); if(policeApply != null){ //查詢對應的清單數據 List<GoodsBill> goodsBillList = gb.findallByApplyNo(policeApply.getApplyNo()); for (GoodsBill goodsBill : goodsBillList) { //調撥狀態 if(goodsBill.getDbQuantity()>0){ //根據gooseId查詢調撥清單數據 List<GyTransfer> gyTransfers = gts.findByGoodsId(goodsBill.getGoodsId()); for (GyTransfer gyTransfer : gyTransfers) { GuoyouCount guoyouCount = new GuoyouCount(); guoyouCount.setApplyDate(policeApply.getApplyDate()); guoyouCount.setApplyNo(policeApply.getApplyNo()); guoyouCount.setDeptName(policeApply.getDeptName()); guoyouCount.setAssetSortCode(goodsBill.getAssetSortCode()); guoyouCount.setName(goodsBill.getName()); guoyouCount.setDealStatus("調撥"); guoyouCount.setOutDept(gyTransfer.getDept()); guoyouCount.setStatus(2); gcs.saveGuoyouCount(guoyouCount);
}
} //採購狀態 if(goodsBill.getXzQuantity()>0){ for(int i = 0; i < goodsBill.getXzQuantity(); i++){ GuoyouCount guoyouCount = new GuoyouCount(); guoyouCount.setApplyDate(policeApply.getApplyDate()); guoyouCount.setApplyNo(policeApply.getApplyNo()); guoyouCount.setDeptName(policeApply.getDeptName()); guoyouCount.setAssetSortCode(goodsBill.getAssetSortCode()); guoyouCount.setName(goodsBill.getName()); guoyouCount.setDealStatus("採購"); guoyouCount.setStatus(2); gcs.saveGuoyouCount(guoyouCount); } } } }
}
/** * 國有資產卡片數據臨時編號 * @return */ private String getCardId() {
//獲得規格申請單號 String cardId = ""; SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMdd"); String nowdate = dateF.format(new Date()); Date date = new Date(); String formatDate = dateF.format(date); //獲得當天最大卡片編號 String s= bs.getMaxCardId(formatDate); //判斷單號是否存在 if(s== null || s.length()!=18){ //給單號賦值 cardId = "未入省財廳-"+formatDate+"-001"; }else{ String s1=s.substring(15); int i=Integer.valueOf(s1)+1; StringBuffer sb=new StringBuffer(); String s2=String.valueOf(i); for (int j = 0; j < 3-s2.length(); j++) { sb.append("0"); } if(s2.length()<=3){ s2=sb.toString()+s2; cardId = "未入省財廳-"+formatDate+"-"+s2; }else{ return null; } } return cardId; } /** * 流程完成,若是有調撥,則改變對應國有卡片數據中調撥物資的所屬部門 * @param applyNo */ private void updateGyDept(String applyNo) { PoliceApply policeApply = pas.findByApplyNo(applyNo); if(policeApply != null){ //根據申請部門查詢對應的映射部門 //GyDept gyDept = gds.findGyDept(policeApply.getDeptName()); //查詢對應的清單數據 List<GoodsBill> goodsBillList = gb.findallByApplyNo(policeApply.getApplyNo()); for (GoodsBill goodsBill : goodsBillList) { //調撥狀態 if(goodsBill.getDbQuantity()>0){ //根據gooseId查詢調撥清單數據 List<GyTransfer> gyTransfers = gts.findByGoodsId(goodsBill.getGoodsId()); for (GyTransfer gyTransfer : gyTransfers) { //更新國有資產卡片數據中的所屬部門 bs.updateGyBudgetByCardId(policeApply.getDeptName(),gyTransfer.getCardId());
}
}
} }
} private void deleteDb(String applyNo) { List<GoodsBill> goodsIds = gb.findallByApplyNo(applyNo); for (GoodsBill goodsBill : goodsIds) { if(goodsBill.getDbQuantity()>0){ //設置國有資產卡片數據dpetId狀態爲0 //根據goodsId查到對應的卡片id,再根據卡片id更新 List<GyTransfer> gyTransfers = gts.findByGoodsId(goodsBill.getGoodsId()); if(gyTransfers!=null){ for (GyTransfer gyTransfer : gyTransfers) { bs.updateDeptIdByCardId("0", gyTransfer.getCardId()); } } //刪除gyTransfer表中的記錄 gts.deleteDbByGooodsId(goodsBill.getGoodsId()); } //初始化採購、調撥、獲批數量 Integer shQuantity = 0; Integer xzQuantity = 0; Integer dbQuantity = 0; gb.updateGoodsByGoodsId(shQuantity,xzQuantity,dbQuantity,goodsBill.getGoodsId()); }
}
}
|
導入cxf.xml,cxf-servlet.xml資源文件
配置jaxws:server
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <description>CXF基本配置</description>
<import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxws:server serviceName="itService" address="/leaderapproval" serviceClass="com.plsg.ws.cxftest.CxfService"> <jaxws:serviceBean> <bean class="com.plsg.ws.cxftest.CxfServiceImpl"></bean> </jaxws:serviceBean> <jaxws:inInterceptors> <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"></bean> </jaxws:inInterceptors> <jaxws:outInterceptors> <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"></bean> </jaxws:outInterceptors> </jaxws:server> </beans> |
項目路徑/web.xml中cxf的url-pattern/jaxws:server中的address?wsdl
訪問地址:http://192.168.1.115:8080/plsg/ws/leaderapproval?wsdl
能夠使用soauUI工具進行測試,下面以測試類代碼爲例進行測試
點擊finish後,發現項目中多了一些代碼
package com.plsg.ws.test;
import java.rmi.RemoteException; import com.plsg.ws.cxftest.CxfService; import com.plsg.ws.cxftest.CxfServiceProxy; import com.plsg.ws.cxftest.LeaderApprovalResponseCxfListEntry;
public class Test {
public static void main(String[] args) throws RemoteException { CxfServiceProxy cxfServiceProxy = new CxfServiceProxy(); CxfService cxfService = cxfServiceProxy.getCxfService(); LeaderApprovalResponseCxfListEntry[] approval = cxfService.leaderApproval("027731", "00001", 0, "贊成", 1, "4028819b5b4251ef015b4263d5070003", "1"); for (LeaderApprovalResponseCxfListEntry leader : approval) { System.out.println(leader.getKey()+"="+leader.getValue()); } } } |
測試代碼:
package client;
import java.net.MalformedURLException; import java.net.URL; import org.codehaus.xfire.client.Client; import org.w3c.dom.Document;
public class ClientTest {
public static void main(String[] args) throws MalformedURLException, Exception { System.out.println("-------開始測試-------"); Client client = new Client(new URL("http://192.168.1.115:8080/plsg/ws/leaderapproval?wsdl")); Object[] results = client.invoke("leaderApproval",new Object[]{"1","2", 1, "222", 1, "3", "1"}); Document d = (Document)results[0]; System.out.println(d); System.out.println(results[0]); System.out.println("------結束測試------"); } } |