From f81581ea11ab6ca883ed2437376350e3f9b3922b Mon Sep 17 00:00:00 2001 From: jinqiming <45981669@qq.com> Date: Mon, 23 Nov 2020 18:37:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=8F=E5=88=97=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flowable/FlowModelerController.java | 15 +-- .../system/SysOaLeaveController.java | 29 +++- .../system/SysSequenceController.java | 126 ++++++++++++++++++ snow-admin/src/main/resources/logback.xml | 1 + .../resources/templates/flow/deployment.html | 21 ++- .../src/main/resources/templates/main_v1.html | 89 +++---------- .../resources/templates/system/leave/add.html | 8 +- .../templates/system/leave/edit.html | 8 +- .../templates/system/leave/leave.html | 2 +- .../templates/system/sequence/add.html | 37 +++++ .../templates/system/sequence/edit.html | 38 ++++++ .../templates/system/sequence/sequence.html | 94 +++++++++++++ .../common/constant/SequenceContants.java | 14 ++ .../snow/flowable/config/FlowableConfig.java | 8 +- .../snow/flowable/domain/DeploymentVO.java | 3 +- .../java/com/snow/flowable/domain/TaskVO.java | 64 +++++++++ .../flowable/service/FlowableService.java | 2 +- .../service/impl/FlowableServiceImpl.java | 55 ++++++-- .../src/main/resources/generator.yml | 2 +- .../main/resources/vm/java/controller.java.vm | 1 + .../src/main/resources/vm/java/domain.java.vm | 5 + .../main/resources/vm/java/sub-domain.java.vm | 3 +- .../com/snow/system/domain/SysOaLeave.java | 14 ++ .../com/snow/system/domain/SysSequence.java | 65 +++++++++ .../snow/system/mapper/SysSequenceMapper.java | 68 ++++++++++ .../system/service/ISysSequenceService.java | 68 ++++++++++ .../service/impl/SysSequenceServiceImpl.java | 118 ++++++++++++++++ .../mapper/system/SysOaLeaveMapper.xml | 10 +- .../mapper/system/SysSequenceMapper.xml | 69 ++++++++++ 29 files changed, 920 insertions(+), 117 deletions(-) create mode 100644 snow-admin/src/main/java/com/snow/web/controller/system/SysSequenceController.java create mode 100644 snow-admin/src/main/resources/templates/system/sequence/add.html create mode 100644 snow-admin/src/main/resources/templates/system/sequence/edit.html create mode 100644 snow-admin/src/main/resources/templates/system/sequence/sequence.html create mode 100644 snow-common/src/main/java/com/snow/common/constant/SequenceContants.java create mode 100644 snow-flowable/src/main/java/com/snow/flowable/domain/TaskVO.java create mode 100644 snow-system/src/main/java/com/snow/system/domain/SysSequence.java create mode 100644 snow-system/src/main/java/com/snow/system/mapper/SysSequenceMapper.java create mode 100644 snow-system/src/main/java/com/snow/system/service/ISysSequenceService.java create mode 100644 snow-system/src/main/java/com/snow/system/service/impl/SysSequenceServiceImpl.java create mode 100644 snow-system/src/main/resources/mapper/system/SysSequenceMapper.xml diff --git a/snow-admin/src/main/java/com/snow/web/controller/flowable/FlowModelerController.java b/snow-admin/src/main/java/com/snow/web/controller/flowable/FlowModelerController.java index f97a1a3..ebf6aee 100644 --- a/snow-admin/src/main/java/com/snow/web/controller/flowable/FlowModelerController.java +++ b/snow-admin/src/main/java/com/snow/web/controller/flowable/FlowModelerController.java @@ -1,28 +1,17 @@ package com.snow.web.controller.flowable; -import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.ExcelReader; -import com.alibaba.excel.read.metadata.ReadSheet; import com.snow.common.annotation.Log; import com.snow.common.core.controller.BaseController; import com.snow.common.core.domain.AjaxResult; import com.snow.common.core.page.TableDataInfo; import com.snow.common.enums.BusinessType; -import com.snow.common.utils.poi.ExcelUtil; -import com.snow.flowable.domain.DeploymentDTO; -import com.snow.flowable.domain.DeploymentQueryDTO; -import com.snow.flowable.domain.DeploymentVO; -import com.snow.flowable.domain.TaskBaseDTO; +import com.snow.flowable.domain.*; import com.snow.flowable.service.impl.FlowablePublishServiceImpl; import com.snow.flowable.service.impl.FlowableServiceImpl; -import com.snow.framework.excel.FinanceAlipayFlowListener; import com.snow.framework.util.ShiroUtils; import com.snow.system.domain.FinanceAlipayFlow; -import com.snow.system.domain.FinanceAlipayFlowImport; -import com.snow.system.domain.SysUser; import com.snow.system.service.IFinanceAlipayFlowService; import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.flowable.engine.repository.DeploymentQuery; import org.flowable.task.api.Task; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -95,7 +84,7 @@ public class FlowModelerController extends BaseController { startPage(); Long userId = ShiroUtils.getUserId(); - List taskList = flowableService.findTasksByUserId(String.valueOf(userId), taskBaseDTO); + List taskList = flowableService.findTasksByUserId(String.valueOf(userId), taskBaseDTO); return getDataTable(taskList); } diff --git a/snow-admin/src/main/java/com/snow/web/controller/system/SysOaLeaveController.java b/snow-admin/src/main/java/com/snow/web/controller/system/SysOaLeaveController.java index d1a67f1..2d3402b 100644 --- a/snow-admin/src/main/java/com/snow/web/controller/system/SysOaLeaveController.java +++ b/snow-admin/src/main/java/com/snow/web/controller/system/SysOaLeaveController.java @@ -2,13 +2,16 @@ package com.snow.web.controller.system; import java.util.List; +import com.snow.common.constant.SequenceContants; import com.snow.flowable.domain.CompleteTaskDTO; import com.snow.flowable.domain.StartProcessDTO; import com.snow.flowable.service.impl.FlowableServiceImpl; import com.snow.framework.util.ShiroUtils; import com.snow.system.domain.SysUser; +import com.snow.system.service.ISysSequenceService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.flowable.engine.runtime.ProcessInstance; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; @@ -44,6 +47,8 @@ public class SysOaLeaveController extends BaseController @Autowired private FlowableServiceImpl flowableService; + @Autowired + private ISysSequenceService sequenceService; @RequiresPermissions("system:leave:view") @GetMapping() @@ -100,14 +105,9 @@ public class SysOaLeaveController extends BaseController { SysUser sysUser = ShiroUtils.getSysUser(); - - StartProcessDTO startProcessDTO=new StartProcessDTO(); - startProcessDTO.setBusinessKey(sysOaLeave.getName()+":"+"001"); - startProcessDTO.setProcessDefinitionKey("snow_oa_leave"); - startProcessDTO.setStartUserId(String.valueOf(sysUser.getUserId())); - ProcessInstance processInstance = flowableService.startProcessInstanceByKey(startProcessDTO); - sysOaLeave.setProcessInstanceId(processInstance.getProcessInstanceId()); + String leaveNo = sequenceService.getNewSequenceNo(SequenceContants.OA_LEAVE_SEQUENCE); sysOaLeave.setCreateBy(sysUser.getUserName()); + sysOaLeave.setLeaveNo(leaveNo); int i = sysOaLeaveService.insertSysOaLeave(sysOaLeave); return toAjax(i); } @@ -154,6 +154,21 @@ public class SysOaLeaveController extends BaseController @ResponseBody public AjaxResult editSave(SysOaLeave sysOaLeave) { + SysUser sysUser = ShiroUtils.getSysUser(); + SysOaLeave oldSysOaLeave = sysOaLeaveService.selectSysOaLeaveById(sysOaLeave.getId()); + //发起审批 + StartProcessDTO startProcessDTO=new StartProcessDTO(); + startProcessDTO.setBusinessKey(oldSysOaLeave.getLeaveNo()); + startProcessDTO.setProcessDefinitionKey("snow_oa_leave"); + startProcessDTO.setStartUserId(String.valueOf(sysUser.getUserId())); + ProcessInstance processInstance = flowableService.startProcessInstanceByKey(startProcessDTO); + CompleteTaskDTO CompleteTaskDTO=new CompleteTaskDTO(); + CompleteTaskDTO.setUserId(String.valueOf(sysUser.getUserId())); + flowableService.completeTask(CompleteTaskDTO); + sysOaLeave.setProcessStatus(1); + sysOaLeave.setCreateBy(sysUser.getUserName()); + BeanUtils.copyProperties(sysOaLeave,oldSysOaLeave); + sysOaLeave.setProcessInstanceId(processInstance.getProcessInstanceId()); return toAjax(sysOaLeaveService.updateSysOaLeave(sysOaLeave)); } diff --git a/snow-admin/src/main/java/com/snow/web/controller/system/SysSequenceController.java b/snow-admin/src/main/java/com/snow/web/controller/system/SysSequenceController.java new file mode 100644 index 0000000..614e68d --- /dev/null +++ b/snow-admin/src/main/java/com/snow/web/controller/system/SysSequenceController.java @@ -0,0 +1,126 @@ +package com.snow.web.controller.system; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.snow.common.annotation.Log; +import com.snow.common.enums.BusinessType; +import org.springframework.stereotype.Controller; +import com.snow.system.domain.SysSequence; +import com.snow.system.service.ISysSequenceService; +import com.snow.common.core.controller.BaseController; +import com.snow.common.core.domain.AjaxResult; +import com.snow.common.utils.poi.ExcelUtil; +import com.snow.common.core.page.TableDataInfo; + +/** + * 系统序列设置Controller + * + * @author snow + * @date 2020-11-23 + */ +@Controller +@RequestMapping("/system/sequence") +public class SysSequenceController extends BaseController +{ + private String prefix = "system/sequence"; + + @Autowired + private ISysSequenceService sysSequenceService; + + @RequiresPermissions("system:sequence:view") + @GetMapping() + public String sequence() + { + return prefix + "/sequence"; + } + + /** + * 查询系统序列设置列表 + */ + @RequiresPermissions("system:sequence:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysSequence sysSequence) + { + startPage(); + List list = sysSequenceService.selectSysSequenceList(sysSequence); + return getDataTable(list); + } + + /** + * 导出系统序列设置列表 + */ + @RequiresPermissions("system:sequence:export") + @Log(title = "系统序列设置", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysSequence sysSequence) + { + List list = sysSequenceService.selectSysSequenceList(sysSequence); + ExcelUtil util = new ExcelUtil(SysSequence.class); + return util.exportExcel(list, "sequence"); + } + + /** + * 新增系统序列设置 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存系统序列设置 + */ + @RequiresPermissions("system:sequence:add") + @Log(title = "系统序列设置", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(SysSequence sysSequence) + { + return toAjax(sysSequenceService.insertSysSequence(sysSequence)); + } + + /** + * 修改系统序列设置 + */ + @GetMapping("/edit/{name}") + public String edit(@PathVariable("name") String name, ModelMap mmap) + { + SysSequence sysSequence = sysSequenceService.selectSysSequenceById(name); + mmap.put("sysSequence", sysSequence); + return prefix + "/edit"; + } + + /** + * 修改保存系统序列设置 + */ + @RequiresPermissions("system:sequence:edit") + @Log(title = "系统序列设置", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(SysSequence sysSequence) + { + return toAjax(sysSequenceService.updateSysSequence(sysSequence)); + } + + /** + * 删除系统序列设置 + */ + @RequiresPermissions("system:sequence:remove") + @Log(title = "系统序列设置", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(sysSequenceService.deleteSysSequenceByIds(ids)); + } +} diff --git a/snow-admin/src/main/resources/logback.xml b/snow-admin/src/main/resources/logback.xml index 32b0f79..eab485d 100644 --- a/snow-admin/src/main/resources/logback.xml +++ b/snow-admin/src/main/resources/logback.xml @@ -75,6 +75,7 @@ + diff --git a/snow-admin/src/main/resources/templates/flow/deployment.html b/snow-admin/src/main/resources/templates/flow/deployment.html index dcf303e..ce98b7b 100644 --- a/snow-admin/src/main/resources/templates/flow/deployment.html +++ b/snow-admin/src/main/resources/templates/flow/deployment.html @@ -68,8 +68,6 @@ var capitalStatusDatas = [[${@dict.getType('capital_status')}]]; var flowCategoryDatas = [[${@dict.getType('flow_category')}]]; var prefix = ctx + "modeler"; - var getXmlUrl=prefix+'/getXml?id='; - var getFlowPicture=prefix+'/getFlowPicture?id='; $(function() { var options = { url: prefix + "/list", @@ -137,9 +135,14 @@ title: '操作', align: 'center', formatter: function(value, row, index) { + console.log(JSON.stringify(row.processDefinitionVO)); + var processDefinition= row.processDefinitionVO; + // var getFlowPicture=prefix+'/getFlowPicture?id='+processDefinition.deploymentId+'&resourceName='+processDefinition.diagramResourceName; + var getXmlUrl=prefix+'/getXml?id='+processDefinition.deploymentId+'&resourceName='+processDefinition.resourceName; var actions = []; - actions.push('XML '); - actions.push('流程图 '); + actions.push('流程图 '); + actions.push('XML '); + /* actions.push('流程图 ');*/ actions.push('删除'); return actions.join(''); } @@ -147,6 +150,16 @@ }; $.table.init(options); }); + + /** + * 预览XML + * @param tableId + */ + function previewXml(deploymentId,resourceName) { + console.log(JSON.stringify(deploymentId)); + var preViewUrl=prefix+'/getFlowPicture?id='+deploymentId+'&resourceName='+resourceName; + $.modal.openTab("预览流程图", preViewUrl); + } diff --git a/snow-admin/src/main/resources/templates/main_v1.html b/snow-admin/src/main/resources/templates/main_v1.html index e94736a..fb0c1ed 100644 --- a/snow-admin/src/main/resources/templates/main_v1.html +++ b/snow-admin/src/main/resources/templates/main_v1.html @@ -112,11 +112,11 @@ var incomeExpenditureTypeDatas = [[${@dict.getType('income_expenditure_type')}]]; var capitalStatusDatas = [[${@dict.getType('capital_status')}]]; var billTypeDatas = [[${@dict.getType('bill_type')}]]; - var prefix = ctx + "system/flow"; + var prefix = ctx + "modeler"; $(function() { var options = { - url: prefix + "/list", + url: prefix + "/findTasksByUserId", createUrl: prefix + "/add", updateUrl: prefix + "/edit/{id}", removeUrl: prefix + "/remove", @@ -128,89 +128,42 @@ checkbox: false }, { - field: 'id', - title: 'ID', + field: 'taskId', + title: 'taskId', visible: false }, { - field: 'tradeNo', - title: '交易号', - formatter: function(value, row, index) { - if(value==null||value==''){ - return ''; - }else { - return value.substr(0,8); - } - } + field: 'processDefinitionName', + title: '流程名称' + }, + { + field: 'taskName', + title: '任务名称' + }, + { + field: 'businessKey', + title: '单号' }, { - field: 'orderNo', - title: '商家订单号', - formatter: function(value, row, index) { - if(value==null||value==''){ - return ''; - }else { - return value.substr(0,8); - } - } + field: 'startUserId', + title: '流程发起人' }, { - field: 'goodsName', - title: '商品' + field: 'startTime', + title: '流程发起时间' }, { - field: 'tradePrice', - title: '交易金额' - }, - { - field: 'payTime', - title: '交易支付时间' - }, - { - field: 'billType', - title: '账单类型', - formatter: function(value, row, index) { - return $.table.selectDictLabel(billTypeDatas, value); - } - }, - { - field: 'tradeType', - title: '交易类型', - formatter: function(value, row, index) { - return $.table.selectDictLabel(tradeTypeDatas, value); - } - }, - { - field: 'counterparty', - title: '交易对方' + field: 'createDate', + title: '任务创建时间' }, - { - field: 'tradeStatus', - title: '交易状态', - formatter: function(value, row, index) { - return $.table.selectDictLabel(tradeStatusDatas, value); - } - }, - { - field: 'incomeExpenditureType', - title: '收支类型', - formatter: function(value, row, index) { - return $.table.selectDictLabel(incomeExpenditureTypeDatas, value); - } - }, - - { - field: 'belongUserName', - title: '所属人' - }, { title: '操作', align: 'center', formatter: function(value, row, index) { var actions = []; - actions.push('编辑 '); + actions.push('处理 '); actions.push('删除'); return actions.join(''); } diff --git a/snow-admin/src/main/resources/templates/system/leave/add.html b/snow-admin/src/main/resources/templates/system/leave/add.html index 9387a80..60b4c12 100644 --- a/snow-admin/src/main/resources/templates/system/leave/add.html +++ b/snow-admin/src/main/resources/templates/system/leave/add.html @@ -71,14 +71,14 @@ } $("input[name='startTime']").datetimepicker({ - format: "yyyy-mm-dd", - minView: "month", + format: "yyyy-mm-dd hh:ii:ss", + minView: "hour", autoclose: true }); $("input[name='endTime']").datetimepicker({ - format: "yyyy-mm-dd", - minView: "month", + format: "yyyy-mm-dd hh:ii:ss", + minView: "hour", autoclose: true }); diff --git a/snow-admin/src/main/resources/templates/system/leave/edit.html b/snow-admin/src/main/resources/templates/system/leave/edit.html index 530d341..fa715d7 100644 --- a/snow-admin/src/main/resources/templates/system/leave/edit.html +++ b/snow-admin/src/main/resources/templates/system/leave/edit.html @@ -87,14 +87,14 @@ } $("input[name='startTime']").datetimepicker({ - format: "yyyy-mm-dd", - minView: "month", + format: "yyyy-mm-dd hh:ii:ss", + minView: "hour", autoclose: true }); $("input[name='endTime']").datetimepicker({ - format: "yyyy-mm-dd", - minView: "month", + format: "yyyy-mm-dd hh:ii:ss", + minView: "hour", autoclose: true }); diff --git a/snow-admin/src/main/resources/templates/system/leave/leave.html b/snow-admin/src/main/resources/templates/system/leave/leave.html index 1052320..91c09c2 100644 --- a/snow-admin/src/main/resources/templates/system/leave/leave.html +++ b/snow-admin/src/main/resources/templates/system/leave/leave.html @@ -137,7 +137,7 @@ align: 'center', formatter: function(value, row, index) { var actions = []; - actions.push('编辑 '); + actions.push('发起申请 '); actions.push('删除'); return actions.join(''); } diff --git a/snow-admin/src/main/resources/templates/system/sequence/add.html b/snow-admin/src/main/resources/templates/system/sequence/add.html new file mode 100644 index 0000000..209ed9e --- /dev/null +++ b/snow-admin/src/main/resources/templates/system/sequence/add.html @@ -0,0 +1,37 @@ + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/snow-admin/src/main/resources/templates/system/sequence/edit.html b/snow-admin/src/main/resources/templates/system/sequence/edit.html new file mode 100644 index 0000000..28c3167 --- /dev/null +++ b/snow-admin/src/main/resources/templates/system/sequence/edit.html @@ -0,0 +1,38 @@ + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/snow-admin/src/main/resources/templates/system/sequence/sequence.html b/snow-admin/src/main/resources/templates/system/sequence/sequence.html new file mode 100644 index 0000000..30e81ce --- /dev/null +++ b/snow-admin/src/main/resources/templates/system/sequence/sequence.html @@ -0,0 +1,94 @@ + + + + + + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/snow-common/src/main/java/com/snow/common/constant/SequenceContants.java b/snow-common/src/main/java/com/snow/common/constant/SequenceContants.java new file mode 100644 index 0000000..03d1ae0 --- /dev/null +++ b/snow-common/src/main/java/com/snow/common/constant/SequenceContants.java @@ -0,0 +1,14 @@ +package com.snow.common.constant; + +/** + * @author qimingjin + * @Title: 序列号通用常量 + * @Description: + * @date 2020/11/23 16:39 + */ +public class SequenceContants { + /** + *请假 + */ + public static final String OA_LEAVE_SEQUENCE = "OA_QJ"; +} diff --git a/snow-flowable/src/main/java/com/snow/flowable/config/FlowableConfig.java b/snow-flowable/src/main/java/com/snow/flowable/config/FlowableConfig.java index 979d3a4..a489a64 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/config/FlowableConfig.java +++ b/snow-flowable/src/main/java/com/snow/flowable/config/FlowableConfig.java @@ -3,6 +3,7 @@ package com.snow.flowable.config; import org.flowable.common.engine.impl.EngineDeployer; import org.flowable.engine.impl.rules.RulesDeployer; import org.flowable.spring.SpringProcessEngineConfiguration; +import org.flowable.spring.boot.EngineConfigurationConfigurer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; @@ -18,7 +19,7 @@ import java.util.ArrayList; * @date 2020/11/18 19:16 */ @Configuration -public class FlowableConfig { +public class FlowableConfig{ @Primary @@ -35,6 +36,11 @@ public class FlowableConfig { add(new RulesDeployer()); } }); + //设置流程图显示乱码 + configuration.setActivityFontName("宋体"); + configuration.setLabelFontName("宋体"); + configuration.setAnnotationFontName("宋体"); return configuration; } + } diff --git a/snow-flowable/src/main/java/com/snow/flowable/domain/DeploymentVO.java b/snow-flowable/src/main/java/com/snow/flowable/domain/DeploymentVO.java index 84aa93c..ebc3120 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/domain/DeploymentVO.java +++ b/snow-flowable/src/main/java/com/snow/flowable/domain/DeploymentVO.java @@ -1,6 +1,7 @@ package com.snow.flowable.domain; import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import org.flowable.engine.repository.ProcessDefinition; @@ -20,7 +21,7 @@ public class DeploymentVO implements Serializable { private String name; - @JSONField(format = "YYYY-MM-DD hh:mm:ss") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") private Date deploymentTime; private String category; diff --git a/snow-flowable/src/main/java/com/snow/flowable/domain/TaskVO.java b/snow-flowable/src/main/java/com/snow/flowable/domain/TaskVO.java new file mode 100644 index 0000000..5f8730b --- /dev/null +++ b/snow-flowable/src/main/java/com/snow/flowable/domain/TaskVO.java @@ -0,0 +1,64 @@ +package com.snow.flowable.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author qimingjin + * @Title: + * @Description: + * ASSIGNEE_(受理人):task任务的受理人,就是执行TASK的人,这个又分两种情况(有值,NULL) + * 1),有值的情况:XML流程里面定义的受理人,TASK会直接填入这个人; + * 2),NULL:XML没有指定受理人或者只指定了候选组; + * 没有值的时候,可以使用签收功能去指定受理人,就是候选组里面谁签收谁就成了受理人: + *OWNER_(委托人):受理人委托其他人操作该TASK的时候,受理人就成了委托人OWNER_,其他人就成了受理人ASSIGNEE_ + * @date 2020/11/23 17:40 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class TaskVO implements Serializable { + + private String taskId; + + private String taskName; + + private String processDefinitionName; + + private String description; + + private String owner; + + private String parentTaskId; + + private String tenantId; + + private String Assignee; + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + private Date createDate; + + private String category; + + private String formKey; + + private String processInstanceId; + + private String startUserId; + + private String startUserName; + + private String businessKey; + /** + * 任务发起时间 + */ + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + private Date startTime; +} diff --git a/snow-flowable/src/main/java/com/snow/flowable/service/FlowableService.java b/snow-flowable/src/main/java/com/snow/flowable/service/FlowableService.java index 1d9978c..a893e08 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/service/FlowableService.java +++ b/snow-flowable/src/main/java/com/snow/flowable/service/FlowableService.java @@ -60,7 +60,7 @@ public interface FlowableService { * @param taskBaseDTO * @return */ - List findTasksByUserId(String userId,TaskBaseDTO taskBaseDTO); + List findTasksByUserId(String userId,TaskBaseDTO taskBaseDTO); /** * 完成任务 diff --git a/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowableServiceImpl.java b/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowableServiceImpl.java index eae42b5..eb36a21 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowableServiceImpl.java +++ b/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowableServiceImpl.java @@ -138,7 +138,9 @@ public class FlowableServiceImpl implements FlowableService { InputStream inputStream = repositoryService.getResourceAsStream(id, resourceName); b = IoUtil.readInputStream(inputStream, resourceName); } else { - response.setHeader("Content-Type", "image/png"); + //todo 输出的有乱码,暂时没有解决办法 + response.setHeader("Content-Type", "image/png;charset=UTF-8"); + response.setCharacterEncoding("utf-8"); InputStream inputStream = repositoryService.getResourceAsStream(id, resourceName); b = IoUtil.readInputStream(inputStream, resourceName); } @@ -164,6 +166,8 @@ public class FlowableServiceImpl implements FlowableService { }else { processInstance = runtimeService.startProcessInstanceByKey(startProcessDTO.getProcessDefinitionKey(),startProcessDTO.getBusinessKey()); } + //这个方法最终使用一个ThreadLocal类型的变量进行存储,也就是与当前的线程绑定,所以流程实例启动完毕之后,需要设置为null,防止多线程的时候出问题。 + identityService.setAuthenticatedUserId(null); return processInstance; } @@ -179,18 +183,19 @@ public class FlowableServiceImpl implements FlowableService { } @Override - public List findTasksByUserId(String userId, TaskBaseDTO taskBaseDTO) { + public List findTasksByUserId(String userId, TaskBaseDTO taskBaseDTO) { //根据用户ID获取角色 List sysRoles = roleService.selectRolesByUserId(Long.parseLong(userId)); TaskQuery taskQuery = taskService.createTaskQuery() .or() .taskCandidateOrAssigned(userId); + //这个地方查询回去查询系统的用户组表,希望的是查询自己的用户表 if(!CollectionUtils.isEmpty(sysRoles)) { - taskQuery.or() - .taskCandidateGroupIn(sysRoles.stream().map(t->{ - return String.valueOf(t.getRoleId()); - }).collect(Collectors.toList())); + List roleIds = sysRoles.stream().map(t -> { + return String.valueOf(t.getRoleId()); + }).collect(Collectors.toList()); + taskQuery.taskCandidateGroupIn(roleIds); } if(!StringUtils.isEmpty(taskBaseDTO.getProcessInstanceId())){ taskQuery.processInstanceId(taskBaseDTO.getProcessInstanceId()); @@ -204,12 +209,32 @@ public class FlowableServiceImpl implements FlowableService { if(StringUtils.isEmpty(taskBaseDTO.getDefinitionKey())){ taskQuery.processDefinitionKey(taskBaseDTO.getDefinitionKey()); } - return taskQuery.endOr() - .orderBy(TaskQueryProperty.CREATE_TIME) - .listPage(taskBaseDTO.getFirstResult(),taskBaseDTO.getMaxResults()); + List taskList = taskQuery.endOr() + .orderByTaskCreateTime() + .desc() + .listPage(taskBaseDTO.getFirstResult(), taskBaseDTO.getMaxResults()); + List taskVoList = taskList.stream().map(t -> { + TaskVO taskVO = new TaskVO(); + taskVO.setTaskId(t.getId()); + taskVO.setTaskName(t.getName()); + taskVO.setProcessInstanceId(t.getProcessInstanceId()); + taskVO.setCreateDate(t.getCreateTime()); + taskVO.setFormKey(t.getFormKey()); + taskVO.setParentTaskId(t.getParentTaskId()); + taskVO.setAssignee(t.getAssignee()); + taskVO.setOwner(t.getOwner()); + HistoricProcessInstance historicProcessInstance = getHistoricProcessInstanceById(t.getProcessInstanceId()); + taskVO.setProcessDefinitionName(historicProcessInstance.getProcessDefinitionName()); + taskVO.setStartUserId(historicProcessInstance.getStartUserId()); + taskVO.setBusinessKey(historicProcessInstance.getBusinessKey()); + taskVO.setStartTime(historicProcessInstance.getStartTime()); + return taskVO; + }).collect(Collectors.toList()); + return taskVoList; } + @Override public void completeTask(CompleteTaskDTO completeTaskDTO) { Task task = this.getTask(completeTaskDTO.getTaskId()); @@ -295,4 +320,16 @@ public class FlowableServiceImpl implements FlowableService { return historyService.createHistoricProcessInstanceQuery().finished() .processInstanceId(processInstanceId).count() > 0; } + + public ProcessInstance getProcessInstanceById(String id){ + return runtimeService.createProcessInstanceQuery() + .processInstanceId(id) + .singleResult(); + } + + public HistoricProcessInstance getHistoricProcessInstanceById(String id){ + return historyService.createHistoricProcessInstanceQuery() + .processInstanceId(id) + .singleResult(); + } } diff --git a/snow-generator/src/main/resources/generator.yml b/snow-generator/src/main/resources/generator.yml index b7369fc..61b3268 100644 --- a/snow-generator/src/main/resources/generator.yml +++ b/snow-generator/src/main/resources/generator.yml @@ -2,7 +2,7 @@ # 代码生成 gen: # 作者 - author: snow + author: 阿吉 # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool packageName: com.snow.system # 自动去除表前缀,默认是false diff --git a/snow-generator/src/main/resources/vm/java/controller.java.vm b/snow-generator/src/main/resources/vm/java/controller.java.vm index a2a8fbc..a056df5 100644 --- a/snow-generator/src/main/resources/vm/java/controller.java.vm +++ b/snow-generator/src/main/resources/vm/java/controller.java.vm @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.snow.common.annotation.Log; import com.snow.common.enums.BusinessType; +import org.springframework.stereotype.Controller; import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; import com.snow.common.core.controller.BaseController; diff --git a/snow-generator/src/main/resources/vm/java/domain.java.vm b/snow-generator/src/main/resources/vm/java/domain.java.vm index 83a6718..30d69d9 100644 --- a/snow-generator/src/main/resources/vm/java/domain.java.vm +++ b/snow-generator/src/main/resources/vm/java/domain.java.vm @@ -4,6 +4,10 @@ package ${packageName}.domain; import ${import}; #end import com.snow.common.annotation.Excel; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.snow.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; #if($table.crud || $table.sub) #elseif($table.tree) #end @@ -36,6 +40,7 @@ public class ${ClassName} extends ${Entity} #if($parentheseIndex != -1) @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") #elseif($column.javaType == 'Date') + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") #else @Excel(name = "${comment}") diff --git a/snow-generator/src/main/resources/vm/java/sub-domain.java.vm b/snow-generator/src/main/resources/vm/java/sub-domain.java.vm index e9f5fad..b40198f 100644 --- a/snow-generator/src/main/resources/vm/java/sub-domain.java.vm +++ b/snow-generator/src/main/resources/vm/java/sub-domain.java.vm @@ -4,7 +4,7 @@ package ${packageName}.domain; import ${import}; #end import com.snow.common.annotation.Excel; - +import com.fasterxml.jackson.annotation.JsonFormat; /** * ${subTable.functionName}对象 ${subTableName} * @@ -28,6 +28,7 @@ public class ${subClassName} extends BaseEntity #if($parentheseIndex != -1) @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") #elseif($column.javaType == 'Date') + @JsonFormat(timezone = "GMT+8", pattern = "yyyyMMdd HH:mm:ss") @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") #else @Excel(name = "${comment}") diff --git a/snow-system/src/main/java/com/snow/system/domain/SysOaLeave.java b/snow-system/src/main/java/com/snow/system/domain/SysOaLeave.java index 1240992..e4614a1 100644 --- a/snow-system/src/main/java/com/snow/system/domain/SysOaLeave.java +++ b/snow-system/src/main/java/com/snow/system/domain/SysOaLeave.java @@ -1,6 +1,8 @@ package com.snow.system.domain; import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; import com.snow.common.annotation.Excel; import com.snow.common.core.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -29,6 +31,7 @@ public class SysOaLeave extends BaseEntity /** 开始时间 */ @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") private Date startTime; /** 结束时间 */ @@ -53,6 +56,9 @@ public class SysOaLeave extends BaseEntity /** 附件 */ @Excel(name = "附件") private String fileUrl; + /** 请假单号 */ + @Excel(name = "请假单号") + private String leaveNo; public void setId(Integer id) { @@ -145,6 +151,14 @@ public class SysOaLeave extends BaseEntity return fileUrl; } + public String getLeaveNo() { + return leaveNo; + } + + public void setLeaveNo(String leaveNo) { + this.leaveNo = leaveNo; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/snow-system/src/main/java/com/snow/system/domain/SysSequence.java b/snow-system/src/main/java/com/snow/system/domain/SysSequence.java new file mode 100644 index 0000000..b6d6e41 --- /dev/null +++ b/snow-system/src/main/java/com/snow/system/domain/SysSequence.java @@ -0,0 +1,65 @@ +package com.snow.system.domain; + +import com.snow.common.annotation.Excel; +import com.snow.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 系统序列设置对象 sys_sequence + * + * @author snow + * @date 2020-11-23 + */ +public class SysSequence extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 序列名称 */ + private String name; + + /** 当前值 */ + @Excel(name = "当前值") + private Long currentValue; + + /** 步幅 */ + @Excel(name = "步幅") + private Long increment; + + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + public void setCurrentValue(Long currentValue) + { + this.currentValue = currentValue; + } + + public Long getCurrentValue() + { + return currentValue; + } + public void setIncrement(Long increment) + { + this.increment = increment; + } + + public Long getIncrement() + { + return increment; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("name", getName()) + .append("currentValue", getCurrentValue()) + .append("increment", getIncrement()) + .toString(); + } +} diff --git a/snow-system/src/main/java/com/snow/system/mapper/SysSequenceMapper.java b/snow-system/src/main/java/com/snow/system/mapper/SysSequenceMapper.java new file mode 100644 index 0000000..fb9d6e8 --- /dev/null +++ b/snow-system/src/main/java/com/snow/system/mapper/SysSequenceMapper.java @@ -0,0 +1,68 @@ +package com.snow.system.mapper; + +import java.util.List; +import com.snow.system.domain.SysSequence; + +/** + * 系统序列设置Mapper接口 + * + * @author snow + * @date 2020-11-23 + */ +public interface SysSequenceMapper +{ + /** + * 查询系统序列设置 + * + * @param name 系统序列设置ID + * @return 系统序列设置 + */ + public SysSequence selectSysSequenceById(String name); + + /** + * 查询系统序列设置列表 + * + * @param sysSequence 系统序列设置 + * @return 系统序列设置集合 + */ + public List selectSysSequenceList(SysSequence sysSequence); + + /** + * 新增系统序列设置 + * + * @param sysSequence 系统序列设置 + * @return 结果 + */ + public int insertSysSequence(SysSequence sysSequence); + + /** + * 修改系统序列设置 + * + * @param sysSequence 系统序列设置 + * @return 结果 + */ + public int updateSysSequence(SysSequence sysSequence); + + /** + * 获取下个序列值 + * @param name + * @return + */ + public int getNextSequence(String name); + + /** + * 删除系统序列设置 + * + * @param name 系统序列设置ID + * @return 结果 + */ + public int deleteSysSequenceById(String name); + + /** + * 批量删除系统序列设置 + * + * @param names 需要删除的数据ID + * @return 结果 + */ + public int deleteSysSequenceByIds(String[] names); +} diff --git a/snow-system/src/main/java/com/snow/system/service/ISysSequenceService.java b/snow-system/src/main/java/com/snow/system/service/ISysSequenceService.java new file mode 100644 index 0000000..02ea59b --- /dev/null +++ b/snow-system/src/main/java/com/snow/system/service/ISysSequenceService.java @@ -0,0 +1,68 @@ +package com.snow.system.service; + +import java.util.List; +import com.snow.system.domain.SysSequence; + +/** + * 系统序列设置Service接口 + * + * @author snow + * @date 2020-11-23 + */ +public interface ISysSequenceService +{ + /** + * 查询系统序列设置 + * + * @param name 系统序列设置ID + * @return 系统序列设置 + */ + public SysSequence selectSysSequenceById(String name); + + /** + * 查询系统序列设置列表 + * + * @param sysSequence 系统序列设置 + * @return 系统序列设置集合 + */ + public List selectSysSequenceList(SysSequence sysSequence); + + /** + * 新增系统序列设置 + * + * @param sysSequence 系统序列设置 + * @return 结果 + */ + public int insertSysSequence(SysSequence sysSequence); + + /** + * 修改系统序列设置 + * + * @param sysSequence 系统序列设置 + * @return 结果 + */ + public int updateSysSequence(SysSequence sysSequence); + + /** + * 批量删除系统序列设置 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteSysSequenceByIds(String ids); + + /** + * 删除系统序列设置信息 + * + * @param name 系统序列设置ID + * @return 结果 + */ + public int deleteSysSequenceById(String name); + + /** + * 获取新的序列号 + * @param name + * @return + */ + String getNewSequenceNo(String name); +} diff --git a/snow-system/src/main/java/com/snow/system/service/impl/SysSequenceServiceImpl.java b/snow-system/src/main/java/com/snow/system/service/impl/SysSequenceServiceImpl.java new file mode 100644 index 0000000..3b9579a --- /dev/null +++ b/snow-system/src/main/java/com/snow/system/service/impl/SysSequenceServiceImpl.java @@ -0,0 +1,118 @@ +package com.snow.system.service.impl; + +import java.util.Date; +import java.util.List; + +import cn.hutool.core.date.DateUtil; +import com.snow.common.exception.BusinessException; +import com.snow.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.snow.system.mapper.SysSequenceMapper; +import com.snow.system.domain.SysSequence; +import com.snow.system.service.ISysSequenceService; +import com.snow.common.core.text.Convert; + +/** + * 系统序列设置Service业务层处理 + * + * @author snow + * @date 2020-11-23 + */ +@Service +public class SysSequenceServiceImpl implements ISysSequenceService +{ + @Autowired + private SysSequenceMapper sysSequenceMapper; + + /** + * 查询系统序列设置 + * + * @param name 系统序列设置ID + * @return 系统序列设置 + */ + @Override + public SysSequence selectSysSequenceById(String name) + { + return sysSequenceMapper.selectSysSequenceById(name); + } + + /** + * 查询系统序列设置列表 + * + * @param sysSequence 系统序列设置 + * @return 系统序列设置 + */ + @Override + public List selectSysSequenceList(SysSequence sysSequence) + { + return sysSequenceMapper.selectSysSequenceList(sysSequence); + } + + /** + * 新增系统序列设置 + * + * @param sysSequence 系统序列设置 + * @return 结果 + */ + @Override + public int insertSysSequence(SysSequence sysSequence) + { + return sysSequenceMapper.insertSysSequence(sysSequence); + } + + /** + * 修改系统序列设置 + * + * @param sysSequence 系统序列设置 + * @return 结果 + */ + @Override + public int updateSysSequence(SysSequence sysSequence) + { + return sysSequenceMapper.updateSysSequence(sysSequence); + } + + /** + * 删除系统序列设置对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteSysSequenceByIds(String ids) + { + return sysSequenceMapper.deleteSysSequenceByIds(Convert.toStrArray(ids)); + } + + /** + * 删除系统序列设置信息 + * + * @param name 系统序列设置ID + * @return 结果 + */ + @Override + public int deleteSysSequenceById(String name) + { + return sysSequenceMapper.deleteSysSequenceById(name); + } + + /** + * 获取最新的序列化 + * @param name + * @return + */ + @Override + public String getNewSequenceNo(String name) { + SysSequence sysSequence = selectSysSequenceById(name); + if(StringUtils.isNull(sysSequence)){ + throw new BusinessException("该序列名称不存在"); + } + int nextSequence = sysSequenceMapper.getNextSequence(name); + String date = DateUtil.format(new Date(), "yyyyMMdd"); + StringBuilder sequenceNo=new StringBuilder(name); + sequenceNo.append(date); + sequenceNo.append(String.format("%04d",nextSequence)); + return sequenceNo.toString(); + } +} diff --git a/snow-system/src/main/resources/mapper/system/SysOaLeaveMapper.xml b/snow-system/src/main/resources/mapper/system/SysOaLeaveMapper.xml index 11bd1fa..ca8df0d 100644 --- a/snow-system/src/main/resources/mapper/system/SysOaLeaveMapper.xml +++ b/snow-system/src/main/resources/mapper/system/SysOaLeaveMapper.xml @@ -20,15 +20,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + - select id, name, reason, start_time, end_time, process_status, process_instance_id, create_by, create_time, update_time, update_by, apply_person, remark, is_delete, file_url from sys_oa_leave + select id, name,leave_no, reason, start_time, end_time, process_status, process_instance_id, create_by, create_time, update_time, update_by, apply_person, remark, is_delete, file_url from sys_oa_leave + + + and current_value = #{currentValue} + and increment = #{increment} + + + + + + + insert into sys_sequence + + name, + current_value, + increment, + + + #{name}, + #{currentValue}, + #{increment}, + + + + + update sys_sequence + + current_value = #{currentValue}, + increment = #{increment}, + + where name = #{name} + + + + UPDATE sys_sequence + SET current_value = current_value + increment + WHERE name = #{name} + + + delete from sys_sequence where name = #{name} + + + + delete from sys_sequence where name in + + #{name} + + + + \ No newline at end of file