|
@@ -577,6 +577,173 @@ public class WorkReimbursementNewService extends CrudService<WorkReimbursementDa
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 提交存储
|
|
|
+ * @param workReimbursement
|
|
|
+ * @param variables
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public String saveReimbursementThree(WorkReimbursement workReimbursement,Map<String, Object> variables,String processInstanceId) {
|
|
|
+ workReimbursement.setOldDataType(1);
|
|
|
+ User user = UserUtils.getUser();
|
|
|
+ if (StringUtils.isBlank(workReimbursement.getNumber())) {
|
|
|
+ synchronized (SYN_BYTE) {
|
|
|
+ workReimbursement.setNumber(serialNumTplService.genSerialNum(user.getCompany(), WorkReimbursement.SERIAL_BIZCODE));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ super.save(workReimbursement);
|
|
|
+ String str = "";
|
|
|
+ Office office = officeService.get(workReimbursement.getOfficeId());
|
|
|
+
|
|
|
+ str = "报销【" + workReimbursement.getNumber() + "】申请待审批,经办人:" + user.getName()+",总金额:"+workReimbursement.getMoney();
|
|
|
+ String title = "报销【" + workReimbursement.getNumber() + "】申请待审批";
|
|
|
+ updateWorkReimbursementInfo(workReimbursement);
|
|
|
+ // 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
|
|
|
+ identityService.setAuthenticatedUserId(user.getId());
|
|
|
+ // 启动流程
|
|
|
+ String businessKey = workReimbursement.getId().toString();
|
|
|
+ WorkActivityMenu workActivityMenu = workActivityMenuService.findByParentAndOffice("ggh3125f1f194c82bdea93555c750906", office);
|
|
|
+ // 启动流程
|
|
|
+ String processType = workActivityMenu.getProcessType();
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ Activity activity = new Activity();
|
|
|
+ WorkProjectNotify workProjectNotify = UtilNotify
|
|
|
+ .saveNotify(workReimbursement.getId(),
|
|
|
+ null,
|
|
|
+ workReimbursement.getCompanyId(),
|
|
|
+ title,
|
|
|
+ str,
|
|
|
+ "112",
|
|
|
+ "0",
|
|
|
+ "待审批",
|
|
|
+ ""
|
|
|
+ );
|
|
|
+ List<User> users = new ArrayList<>();
|
|
|
+ //部门主任
|
|
|
+ List<User> bmzrs = UserUtils.getByRoleActivityEnname("bmzr",2,office.getId(),"8",workReimbursement.getCreateBy());
|
|
|
+
|
|
|
+ //判定当前登陆人的部门是否是工程一部或者为工程一部的子部门,如果是,则审核人均为工程一部部门主任
|
|
|
+ if("7f776d072d7b4c839cef4e63ce6dbfa5".equals(office.getId()) || office.getParentIds().contains("7f776d072d7b4c839cef4e63ce6dbfa5")){
|
|
|
+ bmzrs = UserUtils.getByRoleActivityEnname("bmzr",2,"7f776d072d7b4c839cef4e63ce6dbfa5","8",workReimbursement.getCreateBy());
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断当前登陆人的部门是否为综合管理部。如果是,则审核人设置为总审室部门主任(王年生)
|
|
|
+ /*if("6c9ca86e941b4a738c1ab9b006976264".equals(office.getId())){
|
|
|
+ bmzrs = UserUtils.getByRoleActivityEnname("bmzr",2,"26f5f4aff4244d8c833cca11f305c612","8",workReimbursement.getCreateBy());
|
|
|
+ }*/
|
|
|
+ //财务主任
|
|
|
+ List<User> cws = UserUtils.getByRoleActivityEnname("cwzg",3,office.getId(),"8",workReimbursement.getCreateBy());
|
|
|
+
|
|
|
+ //财务员工
|
|
|
+ List<User> fpglys = UserUtils.getByRoleActivityEnname("dzfpbxshybxsd",3,office.getId(),"5",workReimbursement.getCreateBy());
|
|
|
+ //总经办负责人
|
|
|
+ List<User> gsldList = UserUtils.getByRoleActivityEnname("zjbfzribvf",3,office.getId(),"8",workReimbursement.getCreateBy());
|
|
|
+ if (StringUtils.isNotBlank(workActivityMenu.getId())) {
|
|
|
+ workProjectNotify.setNotifyRole("");
|
|
|
+ workActivityMenu = workActivityMenuService.get(workActivityMenu.getId());
|
|
|
+ List<Activity> activities = workActivityMenu.getActivities();
|
|
|
+ for (Activity a : activities) {
|
|
|
+ String encount = a.getEncount();
|
|
|
+ String enlist = a.getEnlist();
|
|
|
+ if (a.getRole()!=null && StringUtils.isNotBlank(a.getRole().getEnname())){
|
|
|
+ List enusers = UserUtils.getByRoleActivityEnnames(a.getRole().getEnname(),office.getId(),"8",workReimbursement.getCreateBy());
|
|
|
+ if (enusers.size()==0){
|
|
|
+ workReimbursement.setStatus("1");
|
|
|
+ super.save(workReimbursement);
|
|
|
+ return "流程审批人不能为空,角色"+a.getRole().getName()+"下无用户,请联系管理员!";
|
|
|
+ }
|
|
|
+ variables.put(enlist, enusers);
|
|
|
+ variables.put(encount, enusers.size());
|
|
|
+ }
|
|
|
+ if (a.getDelFlag().equals("0") && a.getCount() == 1) {
|
|
|
+ activity = a;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ buffer.append(activity.getRole().getEnname());
|
|
|
+ if (activity != null && StringUtils.isNotBlank(activity.getId())) {
|
|
|
+ //角色审批
|
|
|
+ if (StringUtils.isNotBlank(activity.getRole().getEnname())) {
|
|
|
+ users = UserUtils.getByRoleActivityEnnames(activity.getRole().getEnname(),office.getId(),"8",workReimbursement.getCreateBy());
|
|
|
+ }
|
|
|
+ //人员审批
|
|
|
+ if (StringUtils.isNotBlank(activity.getUser().getId())) {
|
|
|
+ users.add(activity.getUser());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ workProjectNotify.setId("");
|
|
|
+ } else {
|
|
|
+ if (cws.size()==0 ){
|
|
|
+ workReimbursement.setStatus("1");
|
|
|
+ super.save(workReimbursement);
|
|
|
+ }
|
|
|
+ if (cws.size()==0){
|
|
|
+ return "流程审批人不能为空,办公室下无用户,请联系管理员!";
|
|
|
+ }
|
|
|
+
|
|
|
+ variables.put("cwcount",cws.size());
|
|
|
+ variables.put("cwList",cws);
|
|
|
+ processType = "reimbursementThree";
|
|
|
+ users.addAll(cws);
|
|
|
+ }
|
|
|
+ for (User u : users){
|
|
|
+ workProjectNotify.setUser(u);
|
|
|
+ workProjectNotify.setId("");
|
|
|
+ workProjectNotify.setNotifyRole("办公室审批");
|
|
|
+ workProjectNotifyService.save(workProjectNotify);
|
|
|
+ Map<String,Object> extras = new HashMap<>();
|
|
|
+ extras.put("type","7002");
|
|
|
+ extras.put("id",workProjectNotify.getId());
|
|
|
+ extras.put("procDefKey","112");
|
|
|
+ UserUtils.pushInfoToApp(title,str,extras,u.getId());
|
|
|
+ UserUtils.pushIm(u.getId(),str);
|
|
|
+ }
|
|
|
+ variables.put("type", processType);
|
|
|
+ variables.put("busId", businessKey);
|
|
|
+ variables.put("title", "审批单:" + workReimbursement.getNumber());//设置标题;
|
|
|
+
|
|
|
+ ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processType, businessKey, variables);
|
|
|
+ workReimbursement.setProcessInstance(processInstance);
|
|
|
+ if (StringUtils.isNotBlank(processInstanceId)) {
|
|
|
+ workActivityProcessService.updateProcessInstanceId(processInstance.getId(),processInstanceId);
|
|
|
+ workActivityProcessService.deleteProcessInstanceId(processInstanceId);
|
|
|
+ workActivityProcessService.deleteProcessIdAuditUsers(processInstanceId);
|
|
|
+ }
|
|
|
+ // 更新流程实例ID
|
|
|
+ workReimbursement.setProcessInstanceId(processInstance.getId());
|
|
|
+ workReimbursementDao.updateProcessInstanceId(workReimbursement);
|
|
|
+ //通知添加流程实例ID
|
|
|
+ workProjectNotify.setProcessInstanceId(processInstance.getId());
|
|
|
+ workProjectNotifyService.save(workProjectNotify);
|
|
|
+ List<Activity> list = workActivityMenu.getActivities();
|
|
|
+ if (list != null && list.size() != 0) {
|
|
|
+ workActivityProcessService.saveList(list, processInstance.getId());
|
|
|
+ } else {
|
|
|
+ WorkActivityProcess workActivityProcess = new WorkActivityProcess();
|
|
|
+ workActivityProcess.setProcessKey("reimbursementThree");
|
|
|
+ workActivityProcess.setCount(1);
|
|
|
+ workActivityProcess.setProcessInstanceId(processInstance.getId());
|
|
|
+ workActivityProcess.setIsApproval("0");
|
|
|
+ workActivityProcessService.save(workActivityProcess);
|
|
|
+ workActivityProcess.setCount(2);
|
|
|
+ workActivityProcess.setId("");
|
|
|
+ workActivityProcessService.save(workActivityProcess);
|
|
|
+ workActivityProcess.setCount(3);
|
|
|
+ workActivityProcess.setId("");
|
|
|
+ workActivityProcessService.save(workActivityProcess);
|
|
|
+ workActivityProcess.setCount(4);
|
|
|
+ workActivityProcess.setId("");
|
|
|
+ workActivityProcessService.save(workActivityProcess);
|
|
|
+ workActivityProcessService.save(workActivityProcess);
|
|
|
+ workActivityProcessService.insertAuditsByType(cws,processInstance.getId(),1,1);
|
|
|
+ workActivityProcessService.insertAuditsByType(bmzrs,processInstance.getId(),2,0);
|
|
|
+ workActivityProcessService.insertAuditsByType(fpglys,processInstance.getId(),3,0);
|
|
|
+ workActivityProcessService.insertAuditsByType(gsldList,processInstance.getId(),4,0);
|
|
|
+ }
|
|
|
+ logger.debug("start process of {key={}, bkey={}, pid={}, variables={}}", new Object[]{
|
|
|
+ ActUtils.PD_REIMBURSEMENT[0], businessKey, processInstance.getId(), variables});
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -2190,6 +2357,445 @@ public class WorkReimbursementNewService extends CrudService<WorkReimbursementDa
|
|
|
workReimbursementDao.update(workReimbursement);
|
|
|
return "保存审核意见成功!";
|
|
|
}
|
|
|
+/**
|
|
|
+ * 审核流程
|
|
|
+ * @param workReimbursement
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public String auditSaveReimbursementThree(WorkReimbursement workReimbursement,List<User> auditUsers) {
|
|
|
+ String str = "";
|
|
|
+ String userName = UserUtils.get(workReimbursement.getCreateBy().getId()).getName();
|
|
|
+ Office office = officeService.get(workReimbursement.getOfficeId());
|
|
|
+ String title = "报销【" + workReimbursement.getNumber() + "】申请待审批";
|
|
|
+ if (workReimbursement.getProject()!= null && StringUtils.isNotBlank(workReimbursement.getProject().getId())){
|
|
|
+ str = "报销申请编号:"+workReimbursement.getNumber()+",报销项目:"+workReimbursement.getProject().getProjectName()+",报销费用合计:"+workReimbursement.getMoney()+",报销人:"+userName+",所属部门:"+office.getName();
|
|
|
+ }else {
|
|
|
+ str = "报销申请编号:"+workReimbursement.getNumber()+",非项目报销,报销费用合计:"+workReimbursement.getMoney()+",报销人:"+userName+",所属部门:"+office.getName();
|
|
|
+ }
|
|
|
+ // 对不同环节的业务逻辑进行操作
|
|
|
+ String taskDefKey = workReimbursement.getAct().getTaskDefKey();
|
|
|
+ if (!"modifyApply".equals(taskDefKey) && !taskDefKey.contains("audit") && !taskDefKey.contains("cw") ) {
|
|
|
+ actTaskService.claim(workReimbursement.getAct().getTaskId(), UserUtils.getUser().getId());
|
|
|
+ }else if(taskDefKey.contains("cw")) {
|
|
|
+ //updateWorkReimbursementInfo(workReimbursement);
|
|
|
+ }else{
|
|
|
+ workReimbursement.getAct().setFlag("yes");
|
|
|
+ if("modifyApply".equals(taskDefKey)) {
|
|
|
+ updateWorkReimbursementInfo(workReimbursement);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String comment = "";
|
|
|
+ if (workReimbursement.getStatus().equals("4")){
|
|
|
+ comment = ("yes".equals(workReimbursement.getAct().getFlag())?"[重新申请] ":"[已撤销] ");
|
|
|
+ }else {
|
|
|
+ comment = ("yes".equals(workReimbursement.getAct().getFlag())?"[同意] ":"[驳回] ")+workReimbursement.getAct().getComment();
|
|
|
+ }
|
|
|
+ //yes 的时候状态为审核通过 否则为未通过
|
|
|
+ //1 审核中 2 未通过
|
|
|
+ workReimbursement.setStatus(("yes".equals(workReimbursement.getAct().getFlag()) ? "2" : "4"));
|
|
|
+ Map<String, Object> vars = Maps.newHashMap();
|
|
|
+ //业务逻辑对应的条件表达式
|
|
|
+ String exp = "";
|
|
|
+ String taskCount = "";
|
|
|
+ String notifyRole = "";
|
|
|
+ int key = 0;
|
|
|
+ String enname = "";
|
|
|
+ List<Activity> activitieList = activityService.getByProcessInstanceId(workReimbursement.getProcessInstanceId());
|
|
|
+ WorkActivityMenu workActivityMenu = new WorkActivityMenu();
|
|
|
+ if (activitieList != null && activitieList.size() != 0) {
|
|
|
+ Iterator<Activity> iterator = activitieList.iterator();
|
|
|
+ while (iterator.hasNext()){
|
|
|
+ Activity activityInfo = iterator.next();
|
|
|
+ if (!"reimbursementThree".equals(activityInfo.getProcessKey())){
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ workActivityMenu.setProcessType(activitieList.get(0).getProcessKey());
|
|
|
+ workActivityMenu.setActivities(activitieList);
|
|
|
+ }
|
|
|
+
|
|
|
+ WorkActivityProcess workActivityProcess = new WorkActivityProcess();
|
|
|
+ WorkActivityProcess selectProcess = new WorkActivityProcess();
|
|
|
+ selectProcess.setProcessInstanceId(workReimbursement.getProcessInstanceId());
|
|
|
+ List<WorkActivityProcess> workActivityProcesses = workActivityProcessService.findList(selectProcess);
|
|
|
+ List<Activity> activities = workActivityMenu.getActivities();
|
|
|
+ if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("reimbursementThree")) {
|
|
|
+ key = 1;
|
|
|
+ for (int i = 0; i < workActivityProcesses.size(); i++) {
|
|
|
+ WorkActivityProcess activityProcess = workActivityProcesses.get(i);
|
|
|
+ if (taskDefKey.equals(activityProcess.getActivityTask()) && !taskDefKey.equals("modifyApply")) {
|
|
|
+ taskCount = activityProcess.getCount()+"";
|
|
|
+ workActivityProcess = activityProcess;
|
|
|
+ if (!workActivityProcess.getIsApproval().equals("0")) {
|
|
|
+ workActivityProcess.setId("");
|
|
|
+ }
|
|
|
+ exp = "pass";
|
|
|
+ if (!"yes".equals(workReimbursement.getAct().getFlag())) {
|
|
|
+ workReimbursement.setStatus("4");
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
+ String returnBack = "-1";
|
|
|
+ for (Activity activity : activities) {
|
|
|
+ if (activity.getCount() == activityProcess.getCount()) {
|
|
|
+ returnBack = activity.getReturnBack();
|
|
|
+ notifyRole = activity.getName();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (returnBack.equals("0")) {
|
|
|
+ workActivityProcess.setId("");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
+ }
|
|
|
+ }else if(taskDefKey.equals("modifyApply")){
|
|
|
+ notifyRole = "调整报销";
|
|
|
+ taskCount = "0";
|
|
|
+ exp = "pass";
|
|
|
+ workActivityProcess.setId("");
|
|
|
+ workActivityProcess.setCount(0);
|
|
|
+ if (!"yes".equals(workReimbursement.getAct().getFlag())) {
|
|
|
+ workReimbursement.setStatus("3");
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
+ } else {
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ workActivityMenu.setProcessType("reimbursementThree");
|
|
|
+ for (int i = 0; i < workActivityProcesses.size(); i++) {
|
|
|
+ WorkActivityProcess activityProcess = workActivityProcesses.get(i);
|
|
|
+ String count = activityProcess.getCount() + "";
|
|
|
+ workActivityProcess = activityProcess;
|
|
|
+ if (!workActivityProcess.getIsApproval().equals("0")) {
|
|
|
+ workActivityProcess.setId("");
|
|
|
+ }
|
|
|
+ // 审核环节
|
|
|
+ if ("cw".equals(taskDefKey) && count.contains("1")) {
|
|
|
+ taskCount = "1";
|
|
|
+ exp = "pass";
|
|
|
+ if ("yes".equals(workReimbursement.getAct().getFlag())) {
|
|
|
+ workActivityProcessService.insertAuditsByType(auditUsers,workReimbursement.getProcessInstanceId(),2,1);
|
|
|
+ notifyRole = "部门主任审核";
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
+ enname = "bmzr";
|
|
|
+ vars.put("bmzrList", auditUsers);
|
|
|
+ vars.put("bmzrcount",auditUsers.size());
|
|
|
+
|
|
|
+ } else {
|
|
|
+ notifyRole = "调整报销";
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ } else if ("bmzr".equals(taskDefKey) && count.contains("2")) {
|
|
|
+ taskCount = "2";
|
|
|
+ exp = "pass";
|
|
|
+ if ("yes".equals(workReimbursement.getAct().getFlag())) {
|
|
|
+ workActivityProcessService.insertAuditsByType(auditUsers,workReimbursement.getProcessInstanceId(),2,1);
|
|
|
+ notifyRole = "财务审核";
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
+ enname = "fpglys";
|
|
|
+ vars.put("fpglysList", auditUsers);
|
|
|
+ vars.put("fpglyscount",auditUsers.size());
|
|
|
+ } else {
|
|
|
+ notifyRole = "调整报销";
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ } else if (("fpglys".equals(taskDefKey) || "dzfpbxshybxsd".equals(taskDefKey)) && count.contains("3")) {
|
|
|
+ taskCount = "3";
|
|
|
+ exp = "pass";
|
|
|
+ if ("yes".equals(workReimbursement.getAct().getFlag())) {
|
|
|
+ workActivityProcessService.insertAuditsByType(auditUsers,workReimbursement.getProcessInstanceId(),3,1);
|
|
|
+ notifyRole = "总经办负责人审核";
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
+ enname = "gsld";
|
|
|
+ vars.put("gsldList", auditUsers);
|
|
|
+ vars.put("gsldcount",auditUsers.size());
|
|
|
+ //如果是财务审核,则默认审核通过时即付款
|
|
|
+ if("fpglys".equals(taskDefKey)) {
|
|
|
+ workReimbursement.setPaymentStatus("1");
|
|
|
+ workReimbursementDao.paymentSave(workReimbursement);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ notifyRole = "调整报销";
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ } else if ("gsld".equals(taskDefKey) && count.contains("4")) {
|
|
|
+ taskCount = "4";
|
|
|
+ exp = "pass";
|
|
|
+ if ("yes".equals(workReimbursement.getAct().getFlag())) {
|
|
|
+ notifyRole = "审批通过";
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
+ } else {
|
|
|
+ notifyRole = "调整报销";
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ } else if ("modifyApply".equals(taskDefKey)&& count.contains("0")) {
|
|
|
+ taskCount = "0";
|
|
|
+ notifyRole = "部门负责人审批";
|
|
|
+ exp = "pass";
|
|
|
+ workActivityProcess.setCount(0);
|
|
|
+ enname = "bmzr";
|
|
|
+ if (!"yes".equals(workReimbursement.getAct().getFlag())) {
|
|
|
+ workReimbursement.setStatus("3");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ } else if ("apply_end".equals(taskDefKey)) {
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 设置意见
|
|
|
+ workReimbursement.getAct().setComment(("yes".equals(workReimbursement.getAct().getFlag()) ? "[同意] " : "[驳回] ") + workReimbursement.getAct().getComment());
|
|
|
+ workReimbursement.preUpdate();
|
|
|
+ // 提交流程任务
|
|
|
+ vars.put(exp, "yes".equals(workReimbursement.getAct().getFlag()) ? true : false);
|
|
|
+ vars.put("passs", true);
|
|
|
+ workActivityProcessService.updateProcess(workActivityProcess,workActivityMenu,key,taskCount,workReimbursement.getProcessInstanceId(),taskDefKey,"modifyApply",workReimbursement.getAct().getFlag(),comment, activities);
|
|
|
+ // 提交流程任务
|
|
|
+ actTaskService.complete(workReimbursement.getAct().getTaskId(), workReimbursement.getAct().getProcInsId(), workReimbursement.getAct().getComment(), vars);
|
|
|
+ workReimbursement.setLimitCond("1");
|
|
|
+ boolean state = actTaskService.isProcessEnd(workReimbursement.getAct().getProcInsId());
|
|
|
+ List<User> users = new ArrayList<>();
|
|
|
+ List<User> userList = new ArrayList<>();
|
|
|
+ if (!state) {
|
|
|
+ title = "报销【" + workReimbursement.getNumber() + "】申请通过";
|
|
|
+ str = "报销【" + workReimbursement.getNumber() + "】申请通过,经办人:" + userName+",总金额:"+workReimbursement.getMoney();
|
|
|
+ users.add(workReimbursement.getCreateBy());
|
|
|
+ if ("yes".equals(workReimbursement.getAct().getFlag())) {
|
|
|
+
|
|
|
+ Set<String> set = new HashSet();
|
|
|
+ //添加经办人人员id
|
|
|
+ set.add(workReimbursement.getCreateBy().getId());
|
|
|
+ //判断是否含有有效的报销信息
|
|
|
+ if(null != workReimbursement.getWorkAccountList()) {
|
|
|
+ //添加报销人人员id
|
|
|
+ for (WorkAccount account : workReimbursement.getWorkAccountList()) {
|
|
|
+ set.add(account.getReimbursementUserId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取通知需要的经办人和报销人人员信息
|
|
|
+ List<User> informUser = Lists.newArrayList();
|
|
|
+ for (String userId: set) {
|
|
|
+ informUser.add(UserUtils.get(userId));
|
|
|
+ }
|
|
|
+
|
|
|
+ workReimbursement.setStatus("5");
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(workReimbursement.getId());
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ //遍历需要通知的人员信息 进行通知(经办人和报销人员)
|
|
|
+ for (User user: informUser) {
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(UtilNotify
|
|
|
+ .saveNotify(workReimbursement.getId(),
|
|
|
+ user,
|
|
|
+ workReimbursement.getCompanyId(),
|
|
|
+ title,
|
|
|
+ str,
|
|
|
+ "112",
|
|
|
+ "0",
|
|
|
+ "待通知",
|
|
|
+ notifyRole));
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改还款
|
|
|
+ if(workReimbursement.getReimbursementBackList()!=null&&workReimbursement.getReimbursementBackList().size()>0){
|
|
|
+ for(WorkReimbursementBack workReimbursementBack:workReimbursement.getReimbursementBackList()){
|
|
|
+ if(StringUtils.isNotBlank(workReimbursementBack.getMoney())||!"0".equals(workReimbursementBack.getMoney())){
|
|
|
+ WorkLoan loan=new WorkLoan();
|
|
|
+ double backMoney=Double.parseDouble(workReimbursementBack.getMoney());//本次还款
|
|
|
+ WorkLoan workLoan =workLoanDao.get(workReimbursementBack.getWorkLoan().getId());
|
|
|
+ loan.setId(workLoan.getId());
|
|
|
+ loan.setUpdateBy(UserUtils.getUser());
|
|
|
+ loan.setUpdateDate(new Date());
|
|
|
+ if(workLoan.getRepay()==null){
|
|
|
+ workLoan.setRepay("0");
|
|
|
+ }
|
|
|
+ double repay=Double.parseDouble(workLoan.getRepay());//还款金额
|
|
|
+ double money=Double.parseDouble(workLoan.getMoney());//借款金额
|
|
|
+ if(!"1".equals(workLoan.getRepayState())){//未还款
|
|
|
+ if((backMoney+repay)>=money){
|
|
|
+ loan.setRepay(String.valueOf(money));
|
|
|
+ loan.setRepayState("1");
|
|
|
+
|
|
|
+ }else{
|
|
|
+ loan.setRepay(String.valueOf(repay+backMoney));
|
|
|
+ loan.setRepayState("2");
|
|
|
+
|
|
|
+ }
|
|
|
+ workLoanDao.updateReay(loan);
|
|
|
+ workRepayDao.updateReay(workReimbursementBack.getWorkLoan().getId(),workReimbursement.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(workReimbursement.getId());
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ if (StringUtils.isNotBlank(workReimbursement.getStatus()) && !workReimbursement.getStatus().equals("3")){
|
|
|
+ workReimbursement.setStatus("4");
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(UtilNotify
|
|
|
+ .saveNotify(workReimbursement.getId(),
|
|
|
+ workReimbursement.getCreateBy(),
|
|
|
+ workReimbursement.getCompanyId(),
|
|
|
+ title,
|
|
|
+ str,
|
|
|
+ "112",
|
|
|
+ "0",
|
|
|
+ "待通知",
|
|
|
+ notifyRole));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ workActivityProcessService.deleteProcessIdAuditUsers(workReimbursement.getProcessInstanceId());
|
|
|
+ } else {
|
|
|
+ if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("reimbursementThree")) {
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(workReimbursement.getId());
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ //users.addAll(userList);
|
|
|
+ WorkProjectNotify workProjectNotify = UtilNotify
|
|
|
+ .saveNotify(workReimbursement.getId(),
|
|
|
+ new User(),
|
|
|
+ workReimbursement.getCompanyId(),
|
|
|
+ title,
|
|
|
+ str,
|
|
|
+ "112",
|
|
|
+ "0",
|
|
|
+ "待审批",
|
|
|
+ notifyRole);
|
|
|
+ List<WorkProjectNotify> workProjectNotifys = activityService.getByFlagAndTaskDefKeyList(
|
|
|
+ activities,
|
|
|
+ workProjectNotify,
|
|
|
+ taskDefKey,
|
|
|
+ workReimbursement.getAct().getFlag(),
|
|
|
+ taskCount,
|
|
|
+ workReimbursement.getCreateBy(),
|
|
|
+ workReimbursement.getOfficeId(),
|
|
|
+ "8");
|
|
|
+ for (WorkProjectNotify workProjectNotify1:workProjectNotifys){
|
|
|
+ users.add(workProjectNotify1.getUser());
|
|
|
+ workProjectNotify1.setId("");
|
|
|
+ workProjectNotify1.setIsNewRecord(false);
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(workProjectNotify1);
|
|
|
+ if (!"modifyApply".equals(taskDefKey)){
|
|
|
+ Map<String,Object> extras = new HashMap<>();
|
|
|
+ if ("bmzr".equals(taskDefKey) || "cn".equals(taskDefKey) ){
|
|
|
+ extras.put("type","7001");
|
|
|
+ }else {
|
|
|
+ extras.put("type","7002");
|
|
|
+ }
|
|
|
+ extras.put("id",workProjectNotify.getId());
|
|
|
+ extras.put("procDefKey","112");
|
|
|
+ UserUtils.pushInfoToApp(title,str,extras,workProjectNotify1.getUser().getId());
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (!"yes".equals(workReimbursement.getAct().getFlag())) {//驳回待办
|
|
|
+ title = "报销【" + workReimbursement.getNumber() + "】申请被驳回";
|
|
|
+ str = "报销【" + workReimbursement.getNumber() + "】申请被驳回,请选择重新申请或作废";
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(workReimbursement.getId());
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ //users.addAll(userList);
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(UtilNotify
|
|
|
+ .saveNotify(workReimbursement.getId(),
|
|
|
+ workReimbursement.getCreateBy(),
|
|
|
+ workReimbursement.getCompanyId(),
|
|
|
+ title,
|
|
|
+ str,
|
|
|
+ "112",
|
|
|
+ "0",
|
|
|
+ "重新申请",
|
|
|
+ notifyRole));
|
|
|
+ users.add( workReimbursement.getCreateBy());
|
|
|
+ } else {
|
|
|
+ if (StringUtils.isNotBlank(enname)) {//驳回重新申请待办
|
|
|
+ title = "报销【" + workReimbursement.getNumber() + "】申请待审批";
|
|
|
+ str = "报销【" + workReimbursement.getNumber() + "】申请待审批,经办人:" + userName+",总金额:"+workReimbursement.getMoney();
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(workReimbursement.getId());
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ //users.addAll(userList1);
|
|
|
+ WorkProjectNotify workProjectNotify = UtilNotify
|
|
|
+ .saveNotify(workReimbursement.getId(),
|
|
|
+ new User(),
|
|
|
+ workReimbursement.getCompanyId(),
|
|
|
+ title,
|
|
|
+ str,
|
|
|
+ "112",
|
|
|
+ "0",
|
|
|
+ "待审批",
|
|
|
+ notifyRole);
|
|
|
+ users.addAll(auditUsers);
|
|
|
+ for (User user1:auditUsers){
|
|
|
+ workProjectNotify.setId("");
|
|
|
+ workProjectNotify.setUser(user1);
|
|
|
+ workProjectNotify.setIsNewRecord(false);
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(workProjectNotify);
|
|
|
+ if (!"modifyApply".equals(taskDefKey)){
|
|
|
+ Map<String,Object> extras = new HashMap<>();
|
|
|
+ if ("bmzr".equals(taskDefKey) || "cn".equals(taskDefKey) ){
|
|
|
+ extras.put("type","7001");
|
|
|
+ }else {
|
|
|
+ extras.put("type","7002");
|
|
|
+ }
|
|
|
+ extras.put("id",workProjectNotify.getId());
|
|
|
+ extras.put("procDefKey","112");
|
|
|
+ UserUtils.pushInfoToApp(title,str,extras,user1.getId());
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }else {
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(workReimbursement.getId());
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ users.addAll(userList);
|
|
|
+ users.add(workReimbursement.getCreateBy());
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(UtilNotify
|
|
|
+ .saveNotify(workReimbursement.getId(),
|
|
|
+ workReimbursement.getCreateBy(),
|
|
|
+ workReimbursement.getCompanyId(),
|
|
|
+ title,
|
|
|
+ str,
|
|
|
+ "112",
|
|
|
+ "0",
|
|
|
+ "重新申请",
|
|
|
+ notifyRole));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (users!=null && users.size()!=0) {
|
|
|
+ for (User u : users) {
|
|
|
+ UserUtils.pushIm(u.getId(),str);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (userList!=null && userList.size()!=0) {
|
|
|
+ for (User u : userList) {
|
|
|
+ UserUtils.pushMeIm(u.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ workReimbursementDao.update(workReimbursement);
|
|
|
+ return "保存审核意见成功!";
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 审核流程(电子发票报销)
|