| | |
| | | package com.ruoyi.inspect.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.StandardTreeTemplateBindingVo; |
| | | import com.ruoyi.basic.service.StandardTreeService; |
| | | import com.ruoyi.inspect.mapper.InsOrderTemplateMapper; |
| | | import com.ruoyi.inspect.pojo.InsOrderTemplate; |
| | | import com.ruoyi.inspect.service.InsOrderTemplateService; |
| | | import com.ruoyi.inspect.vo.InsOrderTemplateDetailVo; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | implements InsOrderTemplateService { |
| | | |
| | | private InsOrderTemplateMapper insOrderTemplateMapper; |
| | | |
| | | private StandardTreeService standardTreeService; |
| | | |
| | | @Override |
| | | public int addInsOrderTemplate(InsOrderTemplate insOrderTemplate) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String selectInsOrderTemplateById(Integer id) { |
| | | return insOrderTemplateMapper.selectById(id).getThing(); |
| | | public InsOrderTemplateDetailVo selectInsOrderTemplateById(Integer id) { |
| | | InsOrderTemplate template = insOrderTemplateMapper.selectById(id); |
| | | InsOrderTemplateDetailVo vo = new InsOrderTemplateDetailVo(); |
| | | if (template == null) { |
| | | vo.setTemplateBindings(new ArrayList<>()); |
| | | return vo; |
| | | } |
| | | vo.setThing(template.getThing()); |
| | | // 优先取模板列上持久化的标准ID,历史数据回退到从表单快照 addObj.standardTreeId 解析 |
| | | Integer standardTreeId = template.getStandardTreeId(); |
| | | if (standardTreeId == null) { |
| | | standardTreeId = parseStandardTreeId(template.getThing()); |
| | | } |
| | | vo.setStandardTreeId(standardTreeId); |
| | | if (standardTreeId != null) { |
| | | List<StandardTreeTemplateBindingVo> bindings = standardTreeService.selectTemplateBindings(standardTreeId); |
| | | vo.setTemplateBindings(bindings == null ? new ArrayList<>() : bindings); |
| | | } else { |
| | | vo.setTemplateBindings(new ArrayList<>()); |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | private Integer parseStandardTreeId(String thing) { |
| | | if (StringUtils.isBlank(thing)) { |
| | | return null; |
| | | } |
| | | try { |
| | | JSONObject addObj = JSON.parseObject(thing).getJSONObject("addObj"); |
| | | return addObj == null ? null : addObj.getInteger("standardTreeId"); |
| | | } catch (Exception ignored) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | return insOrderTemplateMapper.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |