| @@ -69,7 +69,7 @@ public class WxFlowAbleController extends BaseController { | |||
| @SystemControllerLog(description = "工作流-用户代办列表") | |||
| public ResultData list(String flowType,Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] FlowAbleController::list"); | |||
| return wxFlowService.list(flowType,pageNum,pageSize,getUserId()); | |||
| return wxFlowService.list(flowType,pageNum,pageSize,getUserId(),getTenantId()); | |||
| } | |||
| /** | |||
| @@ -247,6 +247,19 @@ public class WxFlowAbleController extends BaseController { | |||
| return new ResultData(wxFlowService.modelList(wxFlowModel,pageNum,pageSize)); | |||
| } | |||
| /** | |||
| * 根据业务查询模板 | |||
| */ | |||
| @ApiOperation("根据业务查询模板") | |||
| @GetMapping(value = "/getModelBybusiness") | |||
| @SystemControllerLog(description = "工作流-模板列表") | |||
| public ResultData getModelBybusiness(@ModelAttribute WxFlowModel wxFlowModel) { | |||
| logger.debug("[" + getIpAddr() + "] FlowAbleController::getModelBybusiness"); | |||
| wxFlowModel.setTenantId(getTenantId()); | |||
| return new ResultData(wxFlowService.getModelBybusiness(wxFlowModel)); | |||
| } | |||
| /** | |||
| * 配置列表 | |||
| */ | |||
| @@ -1,11 +1,9 @@ | |||
| package com.iformall.domain.po; | |||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||
| import com.iformall.domain.vo.UserTaskVo; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Transient; | |||
| @@ -42,6 +40,12 @@ public class WxFlowModel extends BaseEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="更新日期",name="updateDate") | |||
| private Date updateDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="流程id",name="flowId") | |||
| private String flowId; | |||
| @io.swagger.annotations.ApiModelProperty(value="流程类型4商铺签约5多径签约6商铺终止7多径终止8账单变更9有价卷上架",name="flowId") | |||
| @Transient | |||
| private Integer flowType; | |||
| @Transient | |||
| private List<UserTaskVo> lists; | |||
| @@ -7,7 +7,14 @@ package com.iformall.enums; | |||
| public enum EnumFlowKey{ | |||
| CONTRACT(1, "contract_flow"), //合同审批 | |||
| BILL(2, "end_bill_flow"),//账单审批 | |||
| END_CONTRACT(3, "end_contract_flow")//终止合同审批 | |||
| END_CONTRACT(3, "end_contract_flow"),//终止合同审批 | |||
| NEW_RENT_CONTRACT(4, "商铺合同签约"), | |||
| NEW_SHOP_CONTRACT(5, "多径点位合同签约"), | |||
| NEW_RENT_END_CONTRACT(6, "商铺合同终止"), | |||
| NEW_SHOP_END_CONTRACT(7, "多经点位合同终止"), | |||
| NEW_BILL_CHANGE(8, "账单应收金额变更"), | |||
| NEW_COUPON_UPLINE(9, "有价券上架"), | |||
| ; | |||
| public static EnumFlowKey getEnum(Integer code) { | |||
| @@ -1,7 +1,7 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| * Created by luozukai | |||
| */ | |||
| public enum EnumTaskType { | |||
| @@ -13,4 +13,6 @@ public interface WxFlowModelMapper extends CommonMapper<WxFlowModel, Long> { | |||
| List<WxFlowModel> findList(WxFlowModel wxFlowModel); | |||
| WxFlowModel selectById(Long id); | |||
| List<WxFlowModel> getModelBybusiness(WxFlowModel wxFlowModel); | |||
| } | |||
| @@ -15,6 +15,7 @@ import java.util.Map; | |||
| * 流程审批服务 | |||
| */ | |||
| public interface WxFlowService { | |||
| String getFlowKeyByType(int flowType,String tenantId); | |||
| /** | |||
| * 更新业务数据状态 | |||
| @@ -39,7 +40,7 @@ public interface WxFlowService { | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| ResultData list(String flowType,Integer pageNum, Integer pageSize,Long userId); | |||
| ResultData list(String flowType,Integer pageNum, Integer pageSize,Long userId,String tenantId); | |||
| /** | |||
| * 审批历史 | |||
| @@ -126,4 +127,10 @@ public interface WxFlowService { | |||
| * @return | |||
| */ | |||
| ResultData updateConfig(WxFlowConfig wxFlowConfig); | |||
| /** | |||
| * 根据业务查询模板 | |||
| * @return | |||
| */ | |||
| List<WxFlowModel> getModelBybusiness(WxFlowModel wxFlowModel); | |||
| } | |||
| @@ -27,6 +27,8 @@ import org.flowable.bpmn.model.*; | |||
| import org.flowable.bpmn.model.Process; | |||
| import org.flowable.common.engine.api.FlowableIllegalArgumentException; | |||
| import org.flowable.engine.*; | |||
| import org.flowable.engine.repository.Deployment; | |||
| import org.flowable.engine.repository.DeploymentBuilder; | |||
| import org.flowable.engine.runtime.Execution; | |||
| import org.flowable.engine.runtime.ProcessInstance; | |||
| import org.flowable.identitylink.api.IdentityLink; | |||
| @@ -105,8 +107,15 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| * @param flowType | |||
| * @return | |||
| */ | |||
| public static String getFlowKeyByType(int flowType){ | |||
| return EnumFlowKey.getEnum(flowType).getMessage(); | |||
| public String getFlowKeyByType(int flowType,String tenantId){ | |||
| WxFlowConfig query = new WxFlowConfig(); | |||
| query.setTenantId(tenantId); | |||
| query.setType(flowType); | |||
| List<WxFlowConfig> configList = wxFlowConfigMapper.findList(query); | |||
| if(CollectionUtils.isNotEmpty(configList)){ | |||
| return configList.get(0).getWxFlowModel().getFlowId(); | |||
| } | |||
| return null; | |||
| } | |||
| /** | |||
| @@ -360,6 +369,11 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| List<Map<String,Object>> variables = (List)params.get("variables"); | |||
| Boolean supplement = (Boolean)params.get("supplement"); | |||
| String flowKey = getFlowKeyByType(flowType,tenantId); | |||
| if(StringUtils.isBlank(flowKey)){ | |||
| return new ResultData(ResultData.ERROR, "您尚未设置审批模板,请先设置。"); | |||
| } | |||
| // 设置节点处理人 | |||
| HashMap<String, Object> map = new HashMap<>(); | |||
| for (Map<String,String> taskAssigneeMap : taskAssignee) { | |||
| @@ -377,7 +391,7 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| map.put("variables",variables); | |||
| map.put("supplement",supplement); | |||
| ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(getFlowKeyByType(flowType), map); | |||
| ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(flowKey, map); | |||
| logger.debug("流程启动,流程id:{}",processInstance.getId()); | |||
| params.put("flowType",flowType); | |||
| @@ -512,13 +526,13 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| } | |||
| @Override | |||
| public ResultData list(String flowType, Integer pageNum, Integer pageSize,Long userId) { | |||
| public ResultData list(String flowType, Integer pageNum, Integer pageSize,Long userId,String tenantId) { | |||
| TaskQuery taskQuery = taskService.createTaskQuery(); | |||
| //流程过滤条件 | |||
| if(StringUtils.isNotBlank(flowType)) { | |||
| List<String> definitionKeyList = new ArrayList<>(); | |||
| for (String ft : flowType.split(",")) { | |||
| definitionKeyList.add(getFlowKeyByType(Integer.parseInt(ft))); | |||
| definitionKeyList.add(getFlowKeyByType(Integer.parseInt(ft),tenantId)); | |||
| } | |||
| if(CollectionUtils.isNotEmpty(definitionKeyList)){ | |||
| taskQuery.processDefinitionKeyIn(definitionKeyList); | |||
| @@ -1143,34 +1157,65 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| @Override | |||
| public ResultData createModel(WxFlowModel wxFlowModel) { | |||
| Process process = new Process(); | |||
| BpmnModel bpmnModel = new BpmnModel(); | |||
| process.setId(getRandomReqNo()); | |||
| List<SequenceFlow> flowList = createFlow(wxFlowModel.getLists().size()); | |||
| for (int i = 0; i < wxFlowModel.getLists().size(); i++){ | |||
| if(i==0){ | |||
| for (int i = 0; i < wxFlowModel.getLists().size(); i++) { | |||
| UserTaskVo taskVo = wxFlowModel.getLists().get(i); | |||
| if (i == 0) { | |||
| StartEvent start = new StartEvent(); | |||
| start.setId("start"); | |||
| start.setName("开始节点"); | |||
| start.setOutgoingFlows(Arrays.asList(flowList.get(0))); | |||
| process.addFlowElement(start); | |||
| process.addFlowElement(flowList.get(0)); | |||
| }else if(i==wxFlowModel.getLists().size()-1){ | |||
| EndEvent endEvent = new EndEvent(); | |||
| endEvent.setId("end"); | |||
| endEvent.setName("结束节点"); | |||
| endEvent.setIncomingFlows(Arrays.asList(flowList.get(i+1))); | |||
| } | |||
| UserTask userTask = new UserTask(); | |||
| userTask.setName("节点"+i); | |||
| userTask.setId("userTask"+i); | |||
| userTask.setName("节点" + (i + 1)); | |||
| userTask.setId("userTask" + (i + 1)); | |||
| List<String> userIdList = new ArrayList<>(); | |||
| String collection = ""; | |||
| for (int j = 0; j < taskVo.getUserList().size(); j++) { | |||
| FlowUserVo userVo = taskVo.getUserList().get(j); | |||
| userIdList.add(userVo.getId() + ""); | |||
| if(j==taskVo.getUserList().size()-1){ | |||
| collection += userVo.getId(); | |||
| }else{ | |||
| collection += userVo.getId()+","; | |||
| } | |||
| } | |||
| if (EnumTaskType.NORMAL.getCode().equals(taskVo.getType()) || EnumTaskType.OR.getCode().equals(taskVo.getType())) { | |||
| userTask.setCandidateUsers(userIdList); | |||
| } else if (EnumTaskType.AND.getCode().equals(taskVo.getType())) { | |||
| MultiInstanceLoopCharacteristics mi = new MultiInstanceLoopCharacteristics(); | |||
| mi.setLoopCardinality(userIdList.size()+""); | |||
| mi.setCollectionString(collection); | |||
| userTask.setLoopCharacteristics(mi); | |||
| } | |||
| userTask.setIncomingFlows(Arrays.asList(flowList.get(i))); | |||
| userTask.setOutgoingFlows(Arrays.asList(flowList.get(i+1))); | |||
| userTask.setOutgoingFlows(Arrays.asList(flowList.get(i + 1))); | |||
| process.addFlowElement(userTask); | |||
| process.addFlowElement(flowList.get(i+1)); | |||
| process.addFlowElement(flowList.get(i + 1)); | |||
| if (i == wxFlowModel.getLists().size() - 1) { | |||
| EndEvent endEvent = new EndEvent(); | |||
| endEvent.setId("end"); | |||
| endEvent.setName("结束节点"); | |||
| endEvent.setIncomingFlows(Arrays.asList(flowList.get(i + 1))); | |||
| process.addFlowElement(endEvent); | |||
| } | |||
| } | |||
| BpmnModel bpmnModel = new BpmnModel(); | |||
| bpmnModel.addProcess(process); | |||
| DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addBpmnModel(process.getId()+".bpmn20.xml", bpmnModel); | |||
| //部署 | |||
| Deployment deploy = deploymentBuilder.deploy(); | |||
| wxFlowModel.setFlowId(process.getId()); | |||
| wxFlowModel.setFlow(JsonUtil.obj2Json(wxFlowModel)); | |||
| if(wxFlowModel.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| @@ -1191,7 +1236,7 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| if(i==0){ | |||
| sequenceFlow.setName("开始"); | |||
| sequenceFlow.setSourceRef("start"); | |||
| sequenceFlow.setTargetRef("userTask"+i); | |||
| sequenceFlow.setTargetRef("userTask"+(i+1)); | |||
| }else if(i == size){ | |||
| sequenceFlow.setName("结束"); | |||
| sequenceFlow.setSourceRef("userTask"+i); | |||
| @@ -1199,13 +1244,28 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| }else{ | |||
| sequenceFlow.setName("sf"+i); | |||
| sequenceFlow.setSourceRef("userTask"+i); | |||
| sequenceFlow.setTargetRef("userTask"+i); | |||
| sequenceFlow.setTargetRef("userTask"+(i+1)); | |||
| } | |||
| result.add(sequenceFlow); | |||
| } | |||
| return result; | |||
| } | |||
| /** | |||
| * 获取随机的流水号(10位) | |||
| * @return | |||
| */ | |||
| public static String getRandomReqNo() { | |||
| int length=10; | |||
| String base = "abcdefghijklmnopqrstuvwxyz"; | |||
| Random random = new Random(); | |||
| StringBuffer sb = new StringBuffer(); | |||
| for (int i = 0; i < length; i++) { | |||
| int number = random.nextInt(base.length()); | |||
| sb.append(base.charAt(number)); | |||
| } | |||
| return sb.toString(); | |||
| } | |||
| @Override | |||
| public PageInfo<WxFlowModel> modelList(WxFlowModel wxFlowModel,Integer pageIndex, Integer pageSize) { | |||
| @@ -1241,4 +1301,9 @@ public class WxFlowServiceImpl implements WxFlowService { | |||
| wxFlowConfigMapper.updateByPrimaryKeySelective(wxFlowConfig); | |||
| return new ResultData(); | |||
| } | |||
| @Override | |||
| public List<WxFlowModel> getModelBybusiness(WxFlowModel wxFlowModel) { | |||
| return wxFlowModelMapper.getModelBybusiness(wxFlowModel); | |||
| } | |||
| } | |||
| @@ -528,7 +528,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| index++; | |||
| if(index >= yearList.size()-1){ | |||
| //endDate = wxRentContract.getRentalEndDate(); | |||
| endDate = null; | |||
| }else{ | |||
| endDate = yearList.get(index+1);//price index 0开始,year.end 从第二年开始 | |||
| @@ -673,16 +672,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| Long price = propertyContract.getPrice(); | |||
| //按月计租 | |||
| // if (propertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode()) | |||
| // ||propertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { | |||
| result = buildRentMonth(wxMerchant, userId, propertyContract, receivePeriod, lease, rentalStartDate, price,isPreview); | |||
| // } else { | |||
| // //如果按日 | |||
| // List<Date> yearList = new ArrayList<>(); | |||
| // yearList.add(rentalStartDate); | |||
| // Map<String, Object> resultMap = buildRent(receivePeriod,new long[]{price}, yearList, Calendar.DAY_OF_MONTH, propertyContract, userId, wxMerchant, 0, isPreview, null); | |||
| // result = (List<WxBillProperty>)resultMap.get("billList"); | |||
| // } | |||
| } | |||
| for (int i = 0; i < result.size(); i++) { | |||
| result.get(i).setPeriod(i+1); | |||
| @@ -696,7 +696,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| logger.info("合同id:{},开始停止...", id); | |||
| //结束审批流 by luozukai | |||
| List<Task> tasks = taskService.createTaskQuery().processDefinitionKey(WxFlowServiceImpl.getFlowKeyByType(1)) | |||
| List<Task> tasks = taskService.createTaskQuery().processDefinitionKey(wxFlowService.getFlowKeyByType(EnumFlowKey.CONTRACT.getCode().intValue(),record.getTenantId())) | |||
| .processVariableValueEquals("businessId", id+"").list(); | |||
| if (!CollectionUtils.isEmpty(tasks)) { | |||
| for (Task task : tasks) { | |||
| @@ -906,9 +906,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| List<BillTimeVo> billTimeVoList = initBillTimeList(wxRentContract.getRentalStartDate(),wxRentContract.getRentalEndDate(),wxRentContract.getAdjustPeriod(),dayType,receivePeriod); | |||
| // for (BillTimeVo vo:billTimeVoList) { | |||
| // System.out.println(sd.format(vo.getStartDate()) + " "+sd.format(vo.getEndDate()) ); | |||
| // } | |||
| int index = 0; | |||
| for (int i = 0; i < billTimeVoList.size(); i++) { | |||
| @@ -920,7 +917,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| index++; | |||
| if(index >= yearList.size()-1){ | |||
| //endDate = wxRentContract.getRentalEndDate(); | |||
| endDate = null; | |||
| }else{ | |||
| endDate = yearList.get(index+1);//price index 0开始,year.end 从第二年开始 | |||
| @@ -1868,9 +1864,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| Double total = new Double(0); | |||
| int[] diff; | |||
| if(sd.format(start).equals("2019-07-01")){ | |||
| System.out.println(); | |||
| } | |||
| //同一天 | |||
| if(sd.format(start).equals(sd.format(end))){ | |||
| int dayCount = DateUtils.getMonthDayCount(start); | |||
| @@ -1955,15 +1948,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| price = dayPrice; | |||
| } | |||
| System.out.println("-------monthStartDate:"+sd.format(monthStartDate)); | |||
| System.out.println("-------monthStartDate:"+sd.format(end)); | |||
| //最后一个月 | |||
| if(sdM.format(monthStartDate).equals(sdM.format(end))){ | |||
| System.out.println("-----------"); | |||
| System.out.println(sd.format(monthStartDate)); | |||
| System.out.println(sd.format(end)); | |||
| diff = DateUtils.getDiff(monthStartDate,end); | |||
| total += price * (diff[1] +1); | |||
| break; | |||
| @@ -1976,17 +1962,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return total; | |||
| } | |||
| public static void main(String[] args) throws Exception{ | |||
| // long tprice = 100; | |||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |||
| Date start = sd.parse("2020-05-02"); | |||
| // Date end = sd.parse("2020-07-28"); | |||
| // System.out.println("===="+new WxRentContractServiceImpl().getNeedPay(tprice,0,start,end));; | |||
| SimpleDateFormat sdD = new SimpleDateFormat("d"); | |||
| System.out.println(sdD.format(start)); | |||
| } | |||
| public static List<BillTimeVo> initBillTimeList(Date start,Date end,Integer adjustPeriod,Integer dayType,int receivePeriod){ | |||
| List<BillTimeVo> list = new ArrayList<>(); | |||
| @@ -2006,14 +1981,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| timeVo.setReceiveDate(instance.getTime()); | |||
| //结束时间 | |||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |||
| // System.out.println(sd.format(start)); | |||
| instance.clear(); | |||
| instance.setTime(start); | |||
| instance.add(dayType, receivePeriod); | |||
| instance.add(Calendar.DATE, -1); | |||
| timeVo.setEndDate(instance.getTime()); | |||
| // System.out.println(sd.format(instance.getTime())); | |||
| //自然月 | |||
| if(adjustPeriod.equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ | |||
| @@ -10,6 +10,7 @@ | |||
| <result column="create_user" property="createUser" /> | |||
| <result column="create_date" property="createDate" /> | |||
| <result column="update_date" property="updateDate" /> | |||
| <result column="flow_id" property="flowId" /> | |||
| </resultMap> | |||
| @@ -35,6 +36,15 @@ | |||
| select * from wx_flow_model where id=#{id} | |||
| </select> | |||
| <select id="getModelBybusiness" parameterType="com.iformall.domain.po.WxFlowModel" resultMap="BaseResultMap"> | |||
| select m.* from wx_flow_config w,wx_flow_model m | |||
| where w.model_id = m.id and w.type = #{flowType} | |||
| <if test=" null != tenantId "> | |||
| and w.tenant_id = #{tenantId} | |||
| and m.tenant_id = #{tenantId} | |||
| </if> | |||
| </select> | |||
| </mapper> | |||