| | |
| | | package com.ruoyi.basic.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.numgen.NumberGenerator; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.basic.mapper.StandardTemplateMapper; |
| | | import com.ruoyi.basic.pojo.StandardTemplate; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.basic.service.StandardTemplateService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | private StandardTemplateMapper standardTemplateMapper; |
| | | |
| | | |
| | | private final NumberGenerator<StandardTemplate> numberGenerator; |
| | | |
| | | @Override |
| | | public IPage<StandardTemplate> selectStandardTemplatePageList(Page page, StandardTemplate standardTemplate) { |
| | | return standardTemplateMapper.selectStandardTemplatePageList(page, QueryWrappers.queryWrappers(standardTemplate)); |
| | |
| | | |
| | | @Override |
| | | public int addStandardTemplate(StandardTemplate standardTemplate) { |
| | | if (StringUtils.isBlank(standardTemplate.getNumber())) { |
| | | String giveCode = numberGenerator.generateNumberWithPrefix(5, |
| | | "MB" + DateUtil.format(new Date(), "yyMM"), |
| | | StandardTemplate::getNumber); |
| | | standardTemplate.setNumber(giveCode); |
| | | } |
| | | return standardTemplateMapper.insert(standardTemplate); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public String getStandTempThingById(Integer templateId) { |
| | | StandardTemplate standardTemplate = standardTemplateMapper.selectOne(Wrappers.<StandardTemplate>lambdaQuery() |
| | | .eq(StandardTemplate::getId, templateId) |
| | | .select(StandardTemplate::getThing)); |
| | | StandardTemplate standardTemplate = standardTemplateMapper.selectById(templateId); |
| | | if(standardTemplate==null){ |
| | | return null; |
| | | }else{ |
| | | return standardTemplate.getThing(); |
| | | } |
| | | // 查询压缩后的数据 |
| | | // String thing = standardTemplateMapper.selectCompressThing(templateId); |
| | | // if (StringUtils.isNotBlank(thing)) { |
| | | // try { |
| | | // return DecompressMySQLData.decompress(java.util.Base64.getDecoder().decode(thing)); |
| | | // } catch (Exception e) { |
| | | // throw new RuntimeException(e); |
| | | // } |
| | | // } else { |
| | | // return null; |
| | | // } |
| | | } |
| | | |
| | | @Override |
| | | public String getStandTempNameById(Integer templateId) { |
| | | StandardTemplate standardTemplate = standardTemplateMapper.selectOne(Wrappers.<StandardTemplate>lambdaQuery() |
| | | .eq(StandardTemplate::getId, templateId) |
| | | .select(StandardTemplate::getName)); |
| | | StandardTemplate standardTemplate = standardTemplateMapper.selectById(templateId); |
| | | if(standardTemplate==null){ |
| | | return null; |
| | | }else{ |
| | |
| | | @Override |
| | | public StandardTemplate getStandTempIdByName(String name) { |
| | | return standardTemplateMapper.getStandTempIdByName(name); |
| | | } |
| | | |
| | | /** |
| | | * 复制原始记录模板 |
| | | * @param newTemplate |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int copyStandardTemplate(StandardTemplate newTemplate) { |
| | | // 查询旧模板 |
| | | StandardTemplate standardTemplate = baseMapper.selectById(newTemplate.getId()); |
| | | newTemplate.setThing(standardTemplate.getThing()); |
| | | |
| | | if (StringUtils.isBlank(newTemplate.getNumber())) { |
| | | String giveCode = numberGenerator.generateNumberWithPrefix(5, |
| | | "MB" + DateUtil.format(new Date(), "yyMM"), |
| | | StandardTemplate::getNumber); |
| | | newTemplate.setNumber(giveCode); |
| | | } |
| | | newTemplate.setId(null); |
| | | |
| | | return standardTemplateMapper.insert(newTemplate); |
| | | } |
| | | } |