Commit 435a2ab8 by 林永健

Merge remote-tracking branch 'origin/v2.0.1' into v2.0.1

2 parents 5c5fb241 1049866a
...@@ -49,7 +49,6 @@ public class KeHuLvChengAssembler { ...@@ -49,7 +49,6 @@ public class KeHuLvChengAssembler {
String dataTypeCode = JacksonUtil.getStrValueInJsonStrByPath(tplParamDef, "dataTypeCode/defaultValue"); String dataTypeCode = JacksonUtil.getStrValueInJsonStrByPath(tplParamDef, "dataTypeCode/defaultValue");
String stagesStr = JacksonUtil.getStrValueInJsonStrByPath(tplParamDef, "stages/defaultValue"); String stagesStr = JacksonUtil.getStrValueInJsonStrByPath(tplParamDef, "stages/defaultValue");
sopTplDTO.setTplId(StrUtil.sub(SnowFlake.nextSerialNumber(), 0, 8));
sopTplDTO.setTplCron("10 20 7 * * ?"); sopTplDTO.setTplCron("10 20 7 * * ?");
sopTplDTO.setTplRemark("运营端新增模板"); sopTplDTO.setTplRemark("运营端新增模板");
sopTplDTO.setTplStatus((byte) 1); sopTplDTO.setTplStatus((byte) 1);
......
...@@ -46,7 +46,7 @@ public class SopTplController extends BaseController { ...@@ -46,7 +46,7 @@ public class SopTplController extends BaseController {
return sopTplService.getById(tplId); return sopTplService.getById(tplId);
} }
@Operation(summary = "新增模板", description = "新增模板") @Operation(summary = "新增/更新模板", description = "新增/更新模板")
@PostMapping @PostMapping
public SopTpl add(@RequestBody SopTplDTO sopTplDTO) { public SopTpl add(@RequestBody SopTplDTO sopTplDTO) {
return sopTplService.add(sopTplDTO); return sopTplService.add(sopTplDTO);
......
package cn.com.glsx.process.modules.service; package cn.com.glsx.process.modules.service;
import java.util.List;
import java.util.Objects;
import javax.annotation.Resource;
import cn.com.glsx.process.modules.assembler.KeHuLvChengAssembler; import cn.com.glsx.process.modules.assembler.KeHuLvChengAssembler;
import cn.com.glsx.process.modules.converter.SopTplConverter; import cn.com.glsx.process.modules.converter.SopTplConverter;
import cn.com.glsx.process.modules.entity.SopTpl; import cn.com.glsx.process.modules.entity.SopTpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.com.glsx.process.modules.entity.SopTplLink; import cn.com.glsx.process.modules.entity.SopTplLink;
import cn.com.glsx.process.modules.entity.SopTplNode; import cn.com.glsx.process.modules.entity.SopTplNode;
import cn.com.glsx.process.modules.mapper.SopTplLinkMapper; import cn.com.glsx.process.modules.mapper.SopTplLinkMapper;
...@@ -21,7 +10,19 @@ import cn.com.glsx.process.modules.mapper.SopTplMapper; ...@@ -21,7 +10,19 @@ import cn.com.glsx.process.modules.mapper.SopTplMapper;
import cn.com.glsx.process.modules.mapper.SopTplNodeMapper; import cn.com.glsx.process.modules.mapper.SopTplNodeMapper;
import cn.com.glsx.process.modules.model.SopTplDTO; import cn.com.glsx.process.modules.model.SopTplDTO;
import cn.com.glsx.process.modules.model.SopTplSearch; import cn.com.glsx.process.modules.model.SopTplSearch;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.utils.SnowFlake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.Sqls;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
@Service @Service
public class SopTplService { public class SopTplService {
...@@ -82,15 +83,28 @@ public class SopTplService { ...@@ -82,15 +83,28 @@ public class SopTplService {
keHuLvChengAssembler.assemble(sopTplDTO); keHuLvChengAssembler.assemble(sopTplDTO);
SopTpl sopTpl = SopTplConverter.INSTANCE.dto2do(sopTplDTO); SopTpl sopTpl = SopTplConverter.INSTANCE.dto2do(sopTplDTO);
String tplId = sopTpl.getTplId();
if (StrUtil.isEmpty(tplId)) {
tplId = StrUtil.sub(SnowFlake.nextSerialNumber(), 0, 8);
sopTpl.setTplId(tplId);
sopTplMapper.insert(sopTpl); sopTplMapper.insert(sopTpl);
} else {
sopTplNodeMapper.deleteByExample(Example.builder(SopTplNode.class).where(Sqls.custom().andEqualTo("tplId", tplId)).build());
sopTplLinkMapper.deleteByExample(Example.builder(SopTplLink.class).where(Sqls.custom().andEqualTo("tplId", tplId)).build());
sopTplMapper.updateByPrimaryKey(sopTpl);
}
String tplId = sopTpl.getTplId();
List<SopTplNode> nodes = sopTplDTO.getNodes(); List<SopTplNode> nodes = sopTplDTO.getNodes();
nodes.forEach(sopTplNode -> sopTplNode.setTplId(tplId)); for (SopTplNode sopTplNode : nodes) {
sopTplNode.setTplId(tplId);
}
sopTplNodeMapper.insertList(nodes); sopTplNodeMapper.insertList(nodes);
List<SopTplLink> links = sopTplDTO.getLinks(); List<SopTplLink> links = sopTplDTO.getLinks();
links.forEach(sopTplLink -> sopTplLink.setTplId(tplId)); for (SopTplLink sopTplLink : links) {
sopTplLink.setTplId(tplId);
}
sopTplLinkMapper.insertList(links); sopTplLinkMapper.insertList(links);
return sopTpl; return sopTpl;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!