forked from snakerflow/snaker-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa7143a
commit 10bd9ba
Showing
166 changed files
with
32,486 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/main/java/com/snakerflow/app/modules/dao/BorrowDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.snakerflow.app.modules.dao; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import com.snakerflow.app.modules.entity.Borrow; | ||
import com.snakerflow.framework.orm.hibernate.HibernateDao; | ||
|
||
@Component | ||
public class BorrowDao extends HibernateDao<Borrow, Long> { | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/com/snakerflow/app/modules/entity/Borrow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.snakerflow.app.modules.entity; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Table; | ||
|
||
import com.snakerflow.framework.flow.entity.FlowEntity; | ||
|
||
@Entity | ||
@Table(name = "FLOW_BORROW") | ||
public class Borrow extends FlowEntity { | ||
/** | ||
* | ||
*/ | ||
private static final long serialVersionUID = 2523484310463519530L; | ||
private String operator; | ||
private String description; | ||
private Double amount; | ||
private String operateTime; | ||
private String repaymentDate; | ||
public String getOperator() { | ||
return operator; | ||
} | ||
public void setOperator(String operator) { | ||
this.operator = operator; | ||
} | ||
public String getDescription() { | ||
return description; | ||
} | ||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
public Double getAmount() { | ||
return amount; | ||
} | ||
public void setAmount(Double amount) { | ||
this.amount = amount; | ||
} | ||
@Column(name = "operateTime") | ||
public String getOperateTime() { | ||
return operateTime; | ||
} | ||
public void setOperateTime(String operateTime) { | ||
this.operateTime = operateTime; | ||
} | ||
@Column(name = "repaymentDate") | ||
public String getRepaymentDate() { | ||
return repaymentDate; | ||
} | ||
public void setRepaymentDate(String repaymentDate) { | ||
this.repaymentDate = repaymentDate; | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
src/main/java/com/snakerflow/app/modules/service/BorrowManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.snakerflow.app.modules.service; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.snakerflow.framework.flow.service.SnakerEngineFacets; | ||
import com.snakerflow.framework.security.shiro.ShiroUtils; | ||
import com.snakerflow.framework.utils.DateUtils; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.snaker.engine.entity.Order; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.snakerflow.app.modules.dao.BorrowDao; | ||
import com.snakerflow.app.modules.entity.Borrow; | ||
|
||
@Component | ||
public class BorrowManager { | ||
@Autowired | ||
private SnakerEngineFacets facets; | ||
@Autowired | ||
private BorrowDao dao; | ||
|
||
public void save(String processId, String orderId, String taskId, Borrow model) { | ||
/** 流程数据构造开始 */ | ||
Map<String, Object> params = new HashMap<String, Object>(); | ||
params.put("apply.operator", ShiroUtils.getUsername()); | ||
params.put("approval.operator", ShiroUtils.getUsername()); | ||
/** 流程数据构造结束 */ | ||
|
||
/** | ||
* 启动流程并且执行申请任务 | ||
*/ | ||
if (StringUtils.isEmpty(orderId) && StringUtils.isEmpty(taskId)) { | ||
Order order = facets.startAndExecute(processId, ShiroUtils.getUsername(), params); | ||
/** 业务数据处理开始*/ | ||
model.setOrderId(order.getId()); | ||
model.setOperateTime(DateUtils.getCurrentDay()); | ||
model.setOperator(ShiroUtils.getFullname()); | ||
save(model); | ||
} else { | ||
facets.execute(taskId, ShiroUtils.getUsername(), params); | ||
/** 业务数据处理开始*/ | ||
model.setOperator(ShiroUtils.getFullname()); | ||
save(model); | ||
} | ||
} | ||
|
||
/** | ||
* 保存实体 | ||
* @param entity | ||
*/ | ||
public void save(Borrow entity) { | ||
dao.save(entity); | ||
} | ||
|
||
/** | ||
* 根据主键ID删除对应的 | ||
* @param id | ||
*/ | ||
public void delete(Long id) { | ||
dao.delete(id); | ||
} | ||
|
||
/** | ||
* 根据主键ID获取实体 | ||
* @param id | ||
* @return | ||
*/ | ||
public Borrow get(Long id) { | ||
return dao.get(id); | ||
} | ||
|
||
/** | ||
* 获取所有记录 | ||
* @return | ||
*/ | ||
public List<Borrow> getAll() { | ||
return dao.getAll(); | ||
} | ||
|
||
public Borrow findByOrderId(String orderId) { | ||
List<Borrow> results = dao.findBy("orderId", orderId); | ||
if(results != null && results.size() > 0) { | ||
return results.get(0); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/snakerflow/app/modules/web/BorrowController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.snakerflow.app.modules.web; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
import com.snakerflow.app.modules.entity.Borrow; | ||
import com.snakerflow.app.modules.service.BorrowManager; | ||
import com.snakerflow.framework.utils.DateUtils; | ||
|
||
@Controller | ||
@RequestMapping(value = "/flow/borrow") | ||
public class BorrowController { | ||
@Autowired | ||
private BorrowManager manager; | ||
|
||
@RequestMapping(value = "apply", method= RequestMethod.GET) | ||
public String apply(Model model, String processId, String orderId, String taskId) { | ||
model.addAttribute("processId", processId); | ||
model.addAttribute("orderId", orderId); | ||
model.addAttribute("taskId", taskId); | ||
if(StringUtils.isNotEmpty(orderId)) { | ||
model.addAttribute("borrow", manager.findByOrderId(orderId)); | ||
} | ||
if(StringUtils.isEmpty(orderId) || StringUtils.isNotEmpty(taskId)) { | ||
model.addAttribute("operateTime", DateUtils.getCurrentDay()); | ||
return "flow/borrow/apply"; | ||
} else { | ||
return "flow/borrow/applyView"; | ||
} | ||
} | ||
|
||
@RequestMapping(value = "applySave", method= RequestMethod.POST) | ||
public String applySave(String processId, String orderId, String taskId, Borrow model) { | ||
manager.save(processId, orderId, taskId, model); | ||
/** 业务数据处理结束 */ | ||
return "redirect:/snaker/task/active"; | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
src/main/java/com/snakerflow/app/modules/web/LeaveController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.snakerflow.app.modules.web; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
import com.snakerflow.framework.flow.service.SnakerEngineFacets; | ||
import com.snakerflow.framework.security.shiro.ShiroUtils; | ||
|
||
/** | ||
* 请假流程Controller | ||
* 流程特点:多级审批流程、decision节点的表达式写法->${day > 2 ? 'transition5' : 'transition4'} | ||
* 业务数据: | ||
* 所有节点的业务数据均以json格式保存在order、task表的variable字段中 | ||
* 建议业务数据以独立的表保存,通过orderId来关联 | ||
* @author yuqs | ||
* @since 0.1 | ||
*/ | ||
@Controller | ||
@RequestMapping(value = "/flow/leave") | ||
public class LeaveController { | ||
@Autowired | ||
private SnakerEngineFacets facets; | ||
/** | ||
* 请假申请路由方法 | ||
*/ | ||
@RequestMapping(value = "apply", method= RequestMethod.GET) | ||
public String apply(Model model, String processId, String orderId, String taskId, String taskName) { | ||
//将请求参数继续传递给视图页面 | ||
model.addAttribute("processId", processId); | ||
model.addAttribute("orderId", orderId); | ||
model.addAttribute("taskId", taskId); | ||
//设置操作人为当前登录用户,请假流程演示时,将申请人、部门经理审批人、总经理审批人都设置为当前用户 | ||
//可通过修改申请页面的部门经理、总经理输入框来改变下一步的处理人 | ||
model.addAttribute("operator", ShiroUtils.getUsername()); | ||
//根据taskId是否为空来标识当前请求的页面是否为活动任务的节点页面 | ||
if(StringUtils.isEmpty(orderId) || StringUtils.isNotEmpty(taskId)) { | ||
//如果实例id为空或者驳回情况下,返回apply.jsp | ||
return "flow/leave/apply"; | ||
} else { | ||
//如果orderId非空、taskId为空,则表示申请步骤已提交,此时可获取申请数据 | ||
//由于请假流程中的业务数据,是保存在任务表的variable字段中,所以通过flowData方法获取 | ||
//如果业务数据保存在业务表中,需要业务表的orderId字段来关联流程,进而根据orderId查询出业务数据 | ||
model.addAllAttributes(facets.flowData(orderId, taskName)); | ||
//返回申请的查看页面 | ||
return "flow/leave/applyView"; | ||
} | ||
} | ||
|
||
/** | ||
* 部门经理审批路由方法 | ||
*/ | ||
@RequestMapping(value = "approveDept", method= RequestMethod.GET) | ||
public String approveDept(Model model, String processId, String orderId, String taskId, String taskName) { | ||
model.addAttribute("processId", processId); | ||
model.addAttribute("orderId", orderId); | ||
model.addAttribute("taskId", taskId); | ||
if(StringUtils.isNotEmpty(taskId)) { | ||
return "flow/leave/approveDept"; | ||
} else { | ||
model.addAllAttributes(facets.flowData(orderId, taskName)); | ||
return "flow/leave/approveDeptView"; | ||
} | ||
} | ||
|
||
/** | ||
* 总经理审批路由方法 | ||
*/ | ||
@RequestMapping(value = "approveBoss", method= RequestMethod.GET) | ||
public String approveBoss(Model model, String processId, String orderId, String taskId, String taskName) { | ||
model.addAttribute("processId", processId); | ||
model.addAttribute("orderId", orderId); | ||
model.addAttribute("taskId", taskId); | ||
if(StringUtils.isNotEmpty(taskId)) { | ||
return "flow/leave/approveBoss"; | ||
} else { | ||
model.addAllAttributes(facets.flowData(orderId, taskName)); | ||
return "flow/leave/approveBossView"; | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/snakerflow/app/web/PlatformContoller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.snakerflow.app.web; | ||
|
||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
/** | ||
* 平台级别Controller | ||
* @author yuqs | ||
* @since 0.1 | ||
*/ | ||
@Controller | ||
public class PlatformContoller { | ||
/** | ||
* 登录成功后系统首页(一般存在top、left、right三大区域通过frameset包含) | ||
* @param model | ||
* @return | ||
*/ | ||
@RequestMapping(value = "/index" ,method=RequestMethod.GET) | ||
public String main(Model model) { | ||
return "system/index"; | ||
} | ||
|
||
/** | ||
* 如果首页为frameset布局,则存在top | ||
* @param model | ||
* @return | ||
*/ | ||
@RequestMapping(value = "/top" ,method=RequestMethod.GET) | ||
public String top(Model model) { | ||
return "system/top"; | ||
} | ||
|
||
/** | ||
* 如果首页为frameset布局,则存在left | ||
* @param model | ||
* @return | ||
*/ | ||
@RequestMapping(value = "/left" ,method=RequestMethod.GET) | ||
public String left(Model model) { | ||
return "system/left"; | ||
} | ||
|
||
/** | ||
* 如果首页为frameset布局,则存在middle时 | ||
* @param model | ||
* @return | ||
*/ | ||
@RequestMapping(value = "/middle" ,method=RequestMethod.GET) | ||
public String middle(Model model) { | ||
return "system/middle"; | ||
} | ||
|
||
/** | ||
* 如果首页为frameset布局,则存在right | ||
* @param model | ||
* @return | ||
*/ | ||
@RequestMapping(value = "/right" ,method=RequestMethod.GET) | ||
public String right(Model model) { | ||
return "system/right"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.snakerflow.app.web.taglibs; | ||
|
||
import javax.servlet.ServletContext; | ||
import javax.servlet.jsp.JspWriter; | ||
|
||
import com.snakerflow.framework.web.TagDTO; | ||
import com.snakerflow.app.web.taglibs.builder.MenuTagBuilder; | ||
import org.springframework.web.context.WebApplicationContext; | ||
import org.springframework.web.servlet.tags.RequestContextAwareTag; | ||
|
||
/** | ||
* 系统首界面左栏导航菜单自定义标签 | ||
* 该类继承RequestContextAwareTag,主要用于获取WebApplicationContext | ||
* @author yuqs | ||
* @since 0.1 | ||
*/ | ||
public class MenuTag extends RequestContextAwareTag { | ||
|
||
/** | ||
* | ||
*/ | ||
private static final long serialVersionUID = -3041636263647268721L; | ||
//Spring的上下文 | ||
private WebApplicationContext springContext; | ||
//Servlet的上下文 | ||
private ServletContext servletContext = null; | ||
|
||
/** | ||
* 继承RequestContextAwareTag的doStartTagInternal方法,实际上是doStartTag的模板方法 | ||
*/ | ||
@Override | ||
protected int doStartTagInternal() throws Exception { | ||
//获取ServletContext | ||
servletContext = pageContext.getServletContext(); | ||
//获取spring上下文 | ||
springContext = getRequestContext().getWebApplicationContext(); | ||
JspWriter writer = pageContext.getOut(); | ||
if (springContext == null) { | ||
writer.write("获取菜单项失败"); | ||
} else { | ||
TagDTO dto = new TagDTO(servletContext); | ||
dto.setSpringContext(springContext); | ||
MenuTagBuilder builder = springContext.getBean(MenuTagBuilder.class); | ||
writer.write(builder.build(dto)); | ||
} | ||
return 0; | ||
} | ||
} |
Oops, something went wrong.