/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package com.vci.ubcs.flow.engine.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.vci.ubcs.flow.core.entity.ProcessTemplate; import com.vci.ubcs.flow.core.utils.TaskUtil; import com.vci.ubcs.flow.engine.mapper.ProcessTemplateMapper; import com.vci.ubcs.flow.engine.service.ProcessTemplateService; import com.vci.ubcs.starter.web.enumpck.ProcessTemplateTypeEnum; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springblade.core.log.exception.ServiceException; import org.springframework.stereotype.Service; import java.util.*; /** * 流程模板服务实现类 * * @author wang1 */ @Slf4j @Service @AllArgsConstructor public class ProcessTemplateServiceImpl extends ServiceImpl implements ProcessTemplateService { /** * 新增/修改流程模板 * @param processTemplate * @return */ public void saveOrUpdateUser(ProcessTemplate processTemplate){ //校验这个模板下,一类按钮只能有一个模板 QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("button_type_key", processTemplate.getButtonTypeKey()); queryWrapper.eq("template_id", processTemplate.getTemplateId()); if(StringUtils.isNotEmpty(processTemplate.getId())) {//修改的时候,id为空就是新增 queryWrapper.ne("id", processTemplate.getId()); } if(baseMapper.selectOne(queryWrapper)!=null){ throw new ServiceException("模板key:"+processTemplate.getModelKey()+"与模板名称:"+processTemplate.getModelName()+",在此模板下已被配置,请检查!"); } if(StringUtils.isEmpty(processTemplate.getButtonTypeValue())){ processTemplate.setButtonTypeValue(ProcessTemplateTypeEnum.getTextByValue(processTemplate.getButtonTypeKey())); } //新增或者修改 if(StringUtils.isEmpty(processTemplate.getId())){ processTemplate.setCreated(Calendar.getInstance().getTime()); processTemplate.setCreatedBy(TaskUtil.getTaskUser()); processTemplate.setLastUpdated(Calendar.getInstance().getTime()); processTemplate.setLastUpdatedBy(TaskUtil.getTaskUser()); } this.saveOrUpdate(processTemplate); } /** * 删除流程模板 * @param id * @return */ public void deleteProcessTemplate(String id){ baseMapper.deleteById(id); } /** * 流程模板用途 * @return */ public List> processTemplateType(){ ProcessTemplateTypeEnum[] es = ProcessTemplateTypeEnum.values(); List> ll = new ArrayList<>(); for (ProcessTemplateTypeEnum p:es){ Map mi = new HashMap<>(); String value = p.getValue(); String text = p.getText(); mi.put("codee",value); mi.put("namee",text); ll.add(mi); } return ll; } }