BOS Project Note 12th Day
Content:
1, design logistics distribution process
2. Start the logistics distribution process
3. Query Group task, pick Group task
4. Query personal tasks and personal tasks
1. Design the logistics distribution process
Logistics and distribution process
Task assignment based on group tasks, using exclusive gateways, branching selection using process variable implementations
Activiti Graphical Interface:
The ID value of the process corresponds to the key value in the flow definition table and can be used to start the latest version of the process instance
In the Task node:
The general ID value corresponds to the Task_def_key value in the task table that defines the method name for the task in Taskaction in the project Taskdefinitionkey
The value of the candidate Grops property of the Main config corresponds to the name of the roles role, the ID value of group in the Activiti table (role and group synchronization are saved when the value of the group Id should be set to the name of role, Because the ID value is UUID is not easy to read)
Exclusive gateway, branch selection using process variable implementation, condition expression in condition gets the value in the process variable to determine true or false to select Branch
2. Start the process delivery process
Step One: Provide a list method in the work order Management workordermanageaction to query a work order with a start status of "0"
Service Code:
Public list<workordermanage> Findlistnotstart () {Detachedcriteria Detachedcriteria = DetachedCriteria.forClass (workordermanage.class);//Add condition: Start = = 0detachedcriteria.add (Restrictions.eq ("Start", "0"); return Workordermanagedao.findbycondition (Detachedcriteria);}
Step two : Configure Struts.xml
Step three : Provide startranster.jsp page, show work order
Fourth Step : Start the Logistics delivery process by providing the Start method in the Work Order management action
Service Code:
Get the Workordermanage object by ID set start status to 1 start state, and start the logistics delivery process instance
@Resourceprivate processengine processengine;//Start the logistics distribution process, set the work order object to the process variable public void start (String id) {Workordermanage Workordermanage = Workordermanagedao.findbyid (ID); Workordermanage.setstart ("1"); String Processdefinitionkey = "transfer";//Logistics distribution process keymap<string, object> variables = new hashmap<string, Object > Variables.put ("Business Data", Workordermanage);p Rocessengine.getruntimeservice (). Startprocessinstancebykey ( Processdefinitionkey, variables);}
3. Query group tasks
First step : Create a taskaction, provide findgrouptask, query the group (public) task of the currently logged on user
@Controller @scope ("prototype") public class Taskaction extends Actionsupport {@Resourceprivate processengine processengine;/** * Query Group task */public String Findgrouptask () {//task query Taskquery query = Processengine.gettaskservice (). Createtaskquery (); String Candidateuser = Boscontext.getloginuser (). GetId ();//filter Query.taskcandidateuser (Candidateuser) according to group task; Query.orderbytaskcreatetime (). DESC (); list<task> list = Query.list (); Actioncontext.getcontext (). Getvaluestack (). Set ("List", list); return "Grouptasklist";}
Step two : Configure Struts.xml
Step three : grouptask.jsp page display Group task data
<body class= "Easyui-layout" ><div data-options= "region: ' Center '" ><table class= "Easyui-datagrid" fit= "True" nowrap= "false" ><thead><tr><th data-options= "field: ' ID ', width:120" > Task number </th> <th data-options= "field: ' Name ', width:120" > Task Name </th><th data-options= "field: ' Data ', width:520" > Business Data </th><th data-options= "field: ' Pick ', width:120" > Pickup task </th></tr></thead>< Script type= "Text/javascript" >function showData (taskId) {$.post ("${pagecontext.request.contextpath}/taskaction _showdata.action ", {" TaskId ": taskid},function (data) {$ (" #div "+taskid). HTML (data);});} function Toggledata (taskId) {$ ("#div" +taskid). Toggle (); </script><tbody><s:iterator value= "list" var= "task" ><tr><td><s:property value= " ID "/> </td><td><s:property value=" name "/></td><td><a onclick=" ToggleData (' ${ ID} ') "class=" Easyui-linkbutton "> View business Data </a><div style=" Display:none "id="Div${id}" ><script type= "Text/javascript" >showdata (' ${id} ');</script></div></td>< Td><s:a action= "Taskaction_taketask" namespace= "/" cssclass= "Easyui-linkbutton" > Pick <s:param name= " TaskId "value=" id "></s:param></s:a></td></tr></s:iterator></tbody></ Table></div></body>
Fourth Step : Provide the ShowData method in Taskaction, query the process variables according to the task ID
Receive task Idprivate string Taskid;public string GetTaskID () {return taskId;} public void Settaskid (String taskId) {this.taskid = taskId;} /** * AJAX Query Process variables * * @throws ioexception */public String showData () throws IOException {map<string, object> Map = Processengine.gettaskservice (). Getvariables (TaskId); Servletactioncontext.getresponse (). setContentType ("Text/html;charset=utf-8"); Servletactioncontext.getresponse (). Getwriter (). print (map); return NONE;}
Effect:
Toggle () [If the element is visible, toggle to hidden, or if the element is hidden, toggle to visible. ] Control Div's style= "Display:none"
4. Pick Group Tasks
First step : Provide a method for picking group tasks in Taskaction Taketask
/** * Pickup Group Task */public String Taketask () {Processengine.gettaskservice (). Claim (Taskid,boscontext.getloginuser (). GetId ( ); return "Togrouptasklist";}
Step two : Configure Struts.xml
5. Querying Personal tasks
First step : Provide Findpersonaltask method in Taskaction, query personal task
The value of assignee depends on the synchronization setting of the USER_ID value Activiti when the user table synchronizes
/** * Query The current login's personal task */public String findpersonaltask () {taskquery query = Processengine.gettaskservice (). createtaskquery (); Query.taskassignee (Boscontext.getloginuser (). GetId ()); Query.orderbytaskcreatetime (). DESC (); list<task> list = Query.list (); Actioncontext.getcontext (). Getvaluestack (). Set ("List", list); return "Personaltasklist";}
Step two : Configure Struts.xml
Step three : Provide personaltask.jsp
<body class= "Easyui-layout" ><div data-options= "region: ' Center '" ><table class= "Easyui-datagrid" fit= "True" nowrap= "false" ><thead><tr><th data-options= "field: ' ID ', width:120" > Task number </th> <th data-options= "field: ' Name ', width:120" > Task Name </th><th data-options= "field: ' Data ', width:520" > Business Data </th><th data-options= "field: ' Pick ', width:120" > Handling Tasks </th></tr></thead>< Script type= "Text/javascript" >function showData (taskId) {$.post ("${pagecontext.request.contextpath}/taskaction _showdata.action ", {" TaskId ": taskid},function (data) {$ (" #div "+taskid). HTML (data);});} function Toggledata (taskId) {$ ("#div" +taskid). Toggle (); </script><tbody><s:iterator value= "list" var= "task" ><tr><td><s:property value= " ID "/> </td><td><s:property value=" name "/></td><td><a onclick=" ToggleData (' ${ ID} ') "class=" Easyui-linkbutton "> View business Data </a><div style=" Display:none "id="Div${id}" ><script type= "Text/javascript" >showdata (' ${id} ');</script></div></td>< Td><s:a action= "Taskaction_%{taskdefinitionkey}" namespace= "/" cssclass= "Easyui-linkbutton" > Handling Tasks <s: param name= "taskId" value= "id" ></s:param></s:a></td></tr></s:iterator></ Tbody></table></div></body>
6. Handling Tasks
6.1 Handling the Audit work order task
The first step: to provide a way to handle the audit work order in Taskaction
Private integer check;//audit result public integer Getcheck () {return check;} public void SetCheck (Integer check) {this.check = check;} @Resourceprivate Iworkordermanageservice workordermanageservice;/** * For the Audit work Order task */public String checkworkordermanage ( {if (check = = null) {//Jump to audit Work order Form page//query process variable map<string based on task ID, object> map = Processengine.gettaskservice (). Getv Ariables (TASKID); Actioncontext.getcontext (). Getvaluestack (). Set ("Map", map); return "Checkui";} else {//2, modify the Managercheck in the work order to "1" workordermanage workordermanage = (workordermanage) processengine.gettaskservice () . getvariable (TaskId, "Business Data"); Workordermanage.setmanagercheck ("1");//3, if the audit does not pass, modify the work order start to "0" if (check = = 0) { Workordermanage.setstart ("0");} Workordermanageservice.update (workordermanage);//1, Task ID according to task, set process variable checkmap<string, object> variables = new Hashmap<string, object> (); Variables.put ("Check", check);p Rocessengine.gettaskservice (). Complete (TaskId, variables); return "Topersonaltasklist";}}
Step two : Provide the check.jsp page as the form page for the review work order
<body>
6.2 Handling Other tasks
Transact out library task public String Outstore () {map<string, object> variables = new hashmap<string, object> (); Variables.put ("Warehouse Administrator", Boscontext.getloginuser (). GetUserName ());p Rocessengine.gettaskservice (). Complete (TaskId, variables); return "Topersonaltasklist";} Handling distribution Tasks Public String Transfergoods () {map<string, object> variables = new hashmap<string, object> (); Variables.put ("PI", Boscontext.getloginuser () GetUserName ());p Rocessengine.gettaskservice (). Complete (TaskId, variables); return "Topersonaltasklist";} Sign-off task public String receive () {map<string, object> variables = new hashmap<string, object> (); Variables.put ("PI", Boscontext.getloginuser () GetUserName ());p Rocessengine.gettaskservice (). Complete (TaskId, variables); return "Topersonaltasklist";}
Project Review
1. First day of the project
Project Overview
1, project background, software development process (waterfall model), common types of software projects (OA, CRM, ERP, CMS)
2. Build BOS Project Development environment (SSH +mysql+tomcat)
3. Homepage design (Easyui in Layout, accordion, tabs, Ztree plugin (using standard JSON data 4, construct ztree, construct Ztree tree with simple JSON data)
4. Design database using PowerDesigner
2. The second day of the project
1. Extract Basedao and baseaction (generic + reflective)
2. Realize user login (based on Basedao and baseaction), use of verification code
3, Easyui message prompt box Messager (show, alert, confirm, prompt, progress)
4. Easyui menu Button Menubutton
5, write Struts2 Custom Interceptor (if the user is not logged in, automatically jump to the login page)
6. Use Easyui's Validatebox control for form verification
6. Implement password change function based on Windows window
3. Third day of the project
1, basic set part of the demand analysis (pick-up, area, division, fixed area)
The entire BOS project is divided into basic settings, pick-up, transit, routing, reporting parts
2. Export the SQL file according to the provided PDM file, generate the entity class and HBM
3. Usage of the DataGrid in Easyui
Method One: Render the HTML code in the page as a DataGrid style
Mode two: Send AJAX requests to load server-side JSON data to construct DataGrid data
Method Three: Dynamically create the DataGrid with JS code
4, based on the DataGrid implementation of the paging query (implement a common paging query method in Basedao)
5, modify the Pi Echo (based on the load method of the form to implement Echo)
6, add the pick-up (expansion of mobile phone number of the check rule)
7. Delete the pick-up staff (tombstone)
4. Fourth day of the project
1, ocupload One-click Upload JS plug-in use (simulated Ajax asynchronous effect)
2. Using Apache's POI technology to read data from Excel files
3, PINYIN4J tool class use
4, based on (one-click Upload, POI, pinyin4j) to achieve the region's bulk import function
5, the area of the paging query
6. Reconstruct the paging query code (baseaction)
7. Use of ComboBox (dropdown box) control in Easyui
8. Add function for partition based on ComboBox (ComboBox filter function)
9, implementation of the combination of partition conditions paged query
10, based on the POI to achieve the partition data export function
5. Fifth day of the project
1. Add function of the fixed area (add window using ComboBox to display the data of the dispatch, using the DataGrid to display the partition data)
2, Fixed page query
3. Use of the Hessian framework (Remote call technology)
Remote Call technology: Hessian, WebService (CXF, Axis2), httpClient
4, the use of Hessian publishing services in the CRM service, to provide services to inquire customer information
5. Remotely invoke the CRM service in the BOS project
A. Providing an interface in BOS and corresponding to the interface in CRM
B. Creating a proxy object for the client on the interface, invoking the CRM remotely through the proxy object
6. Sixth day of the project
1, Business acceptance (business notice, ticket, work order)
A. Remotely call CRM in the BOS project based on the phone number to obtain customer information and echo back to the page
B. Automatic sorting according to the customer's pickup address
2. The editing function of the DataGrid
A. Set the editor property to specify that the column has editing capabilities
B. Calling method BeginEdit to turn on editing
C. Calling method EndEdit end Edit function
D. Inserting a row in a data table dynamically by Method InsertRow
E. Getting the index of a row by method Getrowindex
F. Ending an edit event with an event Onafteredit listener
3, based on the data table editing function to achieve work order fast input function
7. Seventh day of the project
1. Overview of permissions (authentication, authorization)
2, the common way to control the rights (URL interception, method annotation (proxy), page label control)
3. Getting started with the Shiro framework
A. Functions: Authentication, authorization, session management, encryption
B.shiro Running Process: Application Code----->>subject-------->>securitymanager------>realm
4. Apply Shiro to the BOS project for authentication and authorization
A. Configuring a filter in Web. XML, Spring provides for consolidating the Shiro
B. Configure a bean,id for shirofilter in Applicationcontext.xml
C. Configure a security manager in Applicationcontext.xml and inject it to the Shirofilter
D. Configure a realm in applicationcontext.xml and inject it to the security manager
E. Modify the Login method in Useraction, authenticate using Shiro, and finally call to realm
5. Use Shiro annotations for permission control
A. Turn on annotation functionality (Configure auto proxy, slice class in spring configuration file)
B. Using Shiro annotations on the action method
C. Modifying the construction method of Baseaction
8. Eighth day of the project
1. Initialize permission data (insert permission data into permission table via SQL script)
2. Role management (add, query)
3, user management (add, query)
4, modify the authorization method in the Bosrealm, according to the login to query the corresponding permissions
5. Use Ehcache to cache permission data
A. Importing the Ehcache jar
B. Provide ehcache configuration files (obtained from the jar package)
C. Configure a cache manager in the spring configuration file and inject it to the security manager
6, Shiro label use
7. The left menu of the system is displayed according to the permission of the login.
9. Nineth Day of the project
1. Workflow Concept
2, install plug-in Eclipse plug-in, design process
3. Create 23 tables of the ACTIVITI framework (deployment table, process definition table, process instance table, Task table, Binary tab, process variable table, Group table, user table, relational table)
4. Deployment process definition, query process definition, START process instance, query process instance, process picture name and input stream, query task, handle task
5, the web version of the process designer use
10. Tenth day of the project
1. Querying historical data
2, process variables set, get
3. Group tasks (candidates, candidate groups)
4. Listener (execution, Task)
5. Gateway (exclusive, parallel)
6, Spring Integration Activiti
11.11th Day of the project
1. Deployment process definition (upload to server via ZIP file, complete deployment)
2. Query the latest version of the process definition list data
3, based on the struts2 file download implementation view PNG flowchart slice function
4. View running process instances (run status, Query task node coordinates)
5. Synchronize the role data and user data in the BOS system to the Activiti table
It can also be implemented through a database trigger
12.12th Day of the project
1, Design logistics distribution process (task assignment based on group tasks, use of exclusive gateway, branch selection using process variables implementation)
2. Start the logistics distribution process (set process variables---work order)
3. Query group tasks
4. Pick up group tasks and become personal tasks
5. Query Personal Tasks
6, to handle personal tasks (each task of the handling of an action method)
Framework day58 BOS Project exercises (based on Activiti logistics distribution process, start, inquiry, processing, Project Knowledge Point Review)