/* * 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.engine.entity.FlowTaskUser; import com.vci.ubcs.flow.engine.entity.FlowTaskUserC; import com.vci.ubcs.flow.engine.entity.ProcessStageAttr; import com.vci.ubcs.flow.engine.mapper.ProcessStageAttrMapper; import com.vci.ubcs.flow.engine.service.ProcessStageAttrService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.support.Condition; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 流程阶段服务实现类 * * @author wang1 */ @Slf4j @Service @AllArgsConstructor public class ProcessStageAttrServiceImpl extends ServiceImpl implements ProcessStageAttrService { /** * 新增/修改流程阶段 * @param flowTaskUserC * @return */ @Transactional public void saveOrUpdateUser(FlowTaskUserC flowTaskUserC){ List processStageAttrs = flowTaskUserC.getProcessStageAttr(); String modelKey = flowTaskUserC.getModelKey(); String templateId = flowTaskUserC.getTemplateId(); String taskId = flowTaskUserC.getTaskId(); String taskName = flowTaskUserC.getTaskName(); //直接删除以前的 Map m = new HashMap<>(); m.put("template_id", templateId); m.put("model_key", modelKey); m.put("task_id", taskId); QueryWrapper q = Condition.getQueryWrapper(m, FlowTaskUser.class) .select("id,model_key modelKey,name,description,version,created,last_updated lastUpdated"); int i = baseMapper.deleteByMap(m); System.out.println("删除的属性个数: "+i); List processStages = flowTaskUserC.getProcessStageAttr(); for (ProcessStageAttr processStageAttr:processStages){ processStageAttr.setModelKey(modelKey); processStageAttr.setTemplateId(templateId); processStageAttr.setTaskId(taskId); processStageAttr.setTaskName(taskName); } if(processStages.size()!=0) { this.saveOrUpdateBatch(processStages); } } }