| | |
| | | |
| | | package org.springblade.mdm.program.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.mp.base.BizServiceImpl; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | | import org.springblade.mdm.basesetting.machine.service.MachineService; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.entity.NcNodeHis; |
| | | import org.springblade.mdm.program.mapper.NcNodeHisMapper; |
| | | import org.springblade.mdm.program.vo.NcNodeQueryVO; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 程序节点 |
| | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class NcNodeHisService extends BizServiceImpl<NcNodeHisMapper, NcNodeHis> { |
| | | public final NcNodeService ncNodeService; |
| | | /** |
| | | * 将指定时间时候的节点合并到历史节点数据中,其他数据从node表中删除(只包含不程序包名和程序节点) |
| | | * @param time |
| | | */ |
| | | public void mergeNodeToHisGeTime(Date time) { |
| | | Date okTime = DateUtil.minusSeconds(time,10);//避免mysql数据库时间不精确导致不能同步 |
| | | List<NcNode> nodes = ncNodeService.lambdaQuery().ge(NcNode::getUpdateTime,okTime) |
| | | .in(NcNode::getNodeType,NcNode.TYPE_PROGRAM_PACKAGE,NcNode.TYPE_PROGRAM_FILE).list(); |
| | | |
| | | for(NcNode node : nodes){ |
| | | NcNodeHis nodeHis = new NcNodeHis(); |
| | | BeanUtils.copyProperties(node,nodeHis); |
| | | |
| | | if(baseMapper.countById(nodeHis.getId())>0){ |
| | | this.updateById(nodeHis); |
| | | }else{ |
| | | this.save(nodeHis); |
| | | } |
| | | } |
| | | ncNodeService.deleteOldEditionNodeData(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询节点的历史列表(节点的上级节点”程序包名“因为存在多个版本,所以历史记录也需要根据不同版本程序包名进行查询) |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Transactional(readOnly = true) |
| | | public List<NcNodeVO> historyByNodeId(Long id) { |
| | | NcNodeHis node = this.getById(id); |
| | | /* |
| | | List<NcNodeHis> nodes = lambdaQuery().eq(NcNodeHis::getNodeType,NcNode.TYPE_PROGRAM_PACKAGE) |
| | | .eq(NcNodeHis::getHisSerial, node.getHisSerial()).orderByDesc(NcNodeHis::getCreateTime).list(); |
| | | List<NcNodeVO> voList = new ArrayList<>(); |
| | | nodes.forEach(ncNode -> { |
| | | NcNodeVO vo = new NcNodeVO(); |
| | | BeanUtils.copyProperties(ncNode, vo); |
| | | vo.setCreateUserName(); |
| | | voList.add(vo); |
| | | });*/ |
| | | return this.baseMapper.packageHistoryBySerial(node.getHisSerial()); |
| | | //return voList; |
| | | } |
| | | } |