|
|
@ -2,7 +2,12 @@ package com.xujie.sys.modules.pms.service.Impl; |
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
|
import com.xujie.sys.common.exception.XJException; |
|
|
|
|
|
import com.xujie.sys.common.utils.DateUtils; |
|
|
import com.xujie.sys.common.utils.PageUtils; |
|
|
import com.xujie.sys.common.utils.PageUtils; |
|
|
|
|
|
import com.xujie.sys.common.utils.RandomUtil; |
|
|
|
|
|
import com.xujie.sys.modules.oss.entity.SysOssEntity; |
|
|
|
|
|
import com.xujie.sys.modules.oss.service.SysOssService; |
|
|
import com.xujie.sys.modules.pms.data.*; |
|
|
import com.xujie.sys.modules.pms.data.*; |
|
|
import com.xujie.sys.modules.pms.entity.vo.CheckSubDetailValueVo; |
|
|
import com.xujie.sys.modules.pms.entity.vo.CheckSubDetailValueVo; |
|
|
import com.xujie.sys.modules.pms.mapper.DmTemplateMapper; |
|
|
import com.xujie.sys.modules.pms.mapper.DmTemplateMapper; |
|
|
@ -17,16 +22,18 @@ import com.xujie.sys.modules.sys.entity.SysSceneDynamicControlModelEntity; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
|
import java.io.OutputStream; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.io.InputStream; |
|
|
import java.io.InputStream; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.Comparator; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -48,6 +55,10 @@ public class DmServiceImpl implements DmService { |
|
|
private RedisTemplate<String, Object> redisTemplate; |
|
|
private RedisTemplate<String, Object> redisTemplate; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private SeqRuleService seqRuleService; |
|
|
private SeqRuleService seqRuleService; |
|
|
|
|
|
@Value("${sys-file.file-path}") |
|
|
|
|
|
private String filePath; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SysOssService sysOssService; |
|
|
private static final Logger logger = LoggerFactory.getLogger(HttpClientUtil.class); |
|
|
private static final Logger logger = LoggerFactory.getLogger(HttpClientUtil.class); |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@ -710,40 +721,43 @@ public class DmServiceImpl implements DmService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<DmAttributeTemplateItemData> dmAttributeTemplateItemDetailsSearch(DmAttributeTemplateItemData data) { |
|
|
public List<DmAttributeTemplateItemData> dmAttributeTemplateItemDetailsSearch(DmAttributeTemplateItemData data) { |
|
|
// 需求:并集返回(覆盖表 + 属性项目表),同 itemNo 以覆盖表为准 |
|
|
|
|
|
List<DmAttributeTemplateItemData> propertyList = dmMapper.dmAttributeTemplateItemPropertyList(data); |
|
|
|
|
|
List<DmAttributeTemplateItemData> overrideList = dmMapper.dmAttributeTemplateItemDetailsSearch(data); |
|
|
|
|
|
|
|
|
|
|
|
java.util.LinkedHashMap<String, DmAttributeTemplateItemData> merged = new java.util.LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 先放属性项目表(基表) |
|
|
|
|
|
if (propertyList != null) { |
|
|
|
|
|
for (DmAttributeTemplateItemData p : propertyList) { |
|
|
|
|
|
merged.put(p.getItemNo(), p); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 再放覆盖表(同 key 自动覆盖) |
|
|
|
|
|
if (overrideList != null) { |
|
|
|
|
|
for (DmAttributeTemplateItemData o : overrideList) { |
|
|
|
|
|
merged.put(o.getItemNo(), o); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<DmAttributeTemplateItemData> result = new ArrayList<>(merged.values()); |
|
|
|
|
|
// 有 orderId 的(覆盖表)优先按 orderId,无 orderId 的按 itemNo |
|
|
|
|
|
result.sort((a, b) -> { |
|
|
|
|
|
Integer oa = a.getOrderId() == null ? Integer.MAX_VALUE : a.getOrderId(); |
|
|
|
|
|
Integer ob = b.getOrderId() == null ? Integer.MAX_VALUE : b.getOrderId(); |
|
|
|
|
|
int cmp = oa.compareTo(ob); |
|
|
|
|
|
if (cmp != 0) { |
|
|
|
|
|
return cmp; |
|
|
|
|
|
} |
|
|
|
|
|
String ia = a.getItemNo() == null ? "" : a.getItemNo(); |
|
|
|
|
|
String ib = b.getItemNo() == null ? "" : b.getItemNo(); |
|
|
|
|
|
return ia.compareTo(ib); |
|
|
|
|
|
}); |
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
|
// 当前需求:仅查询 dm_attribute_template_item,不再做“覆盖表 + 属性项目表”合并展示 |
|
|
|
|
|
return dmMapper.dmAttributeTemplateItemDetailsSearch(data); |
|
|
|
|
|
|
|
|
|
|
|
// 原合并展示逻辑(暂注释保留) |
|
|
|
|
|
// List<DmAttributeTemplateItemData> propertyList = dmMapper.dmAttributeTemplateItemPropertyList(data); |
|
|
|
|
|
// List<DmAttributeTemplateItemData> overrideList = dmMapper.dmAttributeTemplateItemDetailsSearch(data); |
|
|
|
|
|
// |
|
|
|
|
|
// java.util.LinkedHashMap<String, DmAttributeTemplateItemData> merged = new java.util.LinkedHashMap<>(); |
|
|
|
|
|
// |
|
|
|
|
|
// // 先放属性项目表(基表) |
|
|
|
|
|
// if (propertyList != null) { |
|
|
|
|
|
// for (DmAttributeTemplateItemData p : propertyList) { |
|
|
|
|
|
// merged.put(p.getItemNo(), p); |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// // 再放覆盖表(同 key 自动覆盖) |
|
|
|
|
|
// if (overrideList != null) { |
|
|
|
|
|
// for (DmAttributeTemplateItemData o : overrideList) { |
|
|
|
|
|
// merged.put(o.getItemNo(), o); |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// |
|
|
|
|
|
// List<DmAttributeTemplateItemData> result = new ArrayList<>(merged.values()); |
|
|
|
|
|
// // 有 orderId 的(覆盖表)优先按 orderId,无 orderId 的按 itemNo |
|
|
|
|
|
// result.sort((a, b) -> { |
|
|
|
|
|
// Integer oa = a.getOrderId() == null ? Integer.MAX_VALUE : a.getOrderId(); |
|
|
|
|
|
// Integer ob = b.getOrderId() == null ? Integer.MAX_VALUE : b.getOrderId(); |
|
|
|
|
|
// int cmp = oa.compareTo(ob); |
|
|
|
|
|
// if (cmp != 0) { |
|
|
|
|
|
// return cmp; |
|
|
|
|
|
// } |
|
|
|
|
|
// String ia = a.getItemNo() == null ? "" : a.getItemNo(); |
|
|
|
|
|
// String ib = b.getItemNo() == null ? "" : b.getItemNo(); |
|
|
|
|
|
// return ia.compareTo(ib); |
|
|
|
|
|
// }); |
|
|
|
|
|
// return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@ -1634,4 +1648,90 @@ public class DmServiceImpl implements DmService { |
|
|
dmMapper.updateDmItemObject(row); |
|
|
dmMapper.updateDmItemObject(row); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 文件上传 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public List<SysOssEntity> upload(MultipartFile[] list, GetParamInData inData) { |
|
|
|
|
|
if (Objects.isNull(list) || list.length == 0) { |
|
|
|
|
|
throw new XJException("上传文件不能为空"); |
|
|
|
|
|
} |
|
|
|
|
|
List<SysOssEntity> ossEntityList = new ArrayList<>(); |
|
|
|
|
|
for (MultipartFile file : list) { |
|
|
|
|
|
// 保存文件信息 |
|
|
|
|
|
SysOssEntity ossEntity = new SysOssEntity(); |
|
|
|
|
|
// 处理文件后缀 |
|
|
|
|
|
int chartIndex = file.getOriginalFilename().lastIndexOf("."); |
|
|
|
|
|
String suffix = ""; |
|
|
|
|
|
String fileName = ""; |
|
|
|
|
|
// 判断是否存在 |
|
|
|
|
|
if (chartIndex > 0) { |
|
|
|
|
|
suffix = file.getOriginalFilename().substring(chartIndex); |
|
|
|
|
|
fileName = file.getOriginalFilename().substring(0, chartIndex); |
|
|
|
|
|
} |
|
|
|
|
|
String newFileName = RandomUtil.getOrderNoByAtomic1("file") + suffix; |
|
|
|
|
|
String basePath = filePath; |
|
|
|
|
|
String baseDatePath = DateUtils.format(new Date()); |
|
|
|
|
|
File baseFilePath = new File(basePath + "\\" + baseDatePath + "\\" + inData.getFolder()); |
|
|
|
|
|
if (!baseFilePath.exists()) { |
|
|
|
|
|
baseFilePath.mkdirs(); |
|
|
|
|
|
} |
|
|
|
|
|
//最终的目录 |
|
|
|
|
|
String finalFileName = baseFilePath.getPath() + "\\" + newFileName; |
|
|
|
|
|
try { |
|
|
|
|
|
baseFilePath = multipartFileToFile(file, finalFileName); |
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
throw new XJException(e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
ossEntity.setUrl(baseFilePath.getPath()); |
|
|
|
|
|
ossEntity.setCreatedBy(inData.getCreateBy()); |
|
|
|
|
|
ossEntity.setFileType(suffix.substring(1)); |
|
|
|
|
|
ossEntity.setFileName(fileName+suffix); |
|
|
|
|
|
ossEntity.setNewFileName(newFileName); |
|
|
|
|
|
ossEntity.setCreateDate(new Date()); |
|
|
|
|
|
ossEntity.setOrderRef1(inData.getOrderRef1()); |
|
|
|
|
|
ossEntity.setOrderRef2(inData.getOrderRef2()); |
|
|
|
|
|
ossEntity.setOrderRef3(inData.getOrderRef3()); |
|
|
|
|
|
ossEntity.setOrderRef4(inData.getOrderRef4()); |
|
|
|
|
|
ossEntity.setOrderReftype("刀模图纸"); |
|
|
|
|
|
sysOssService.save(ossEntity); |
|
|
|
|
|
ossEntityList.add(ossEntity); |
|
|
|
|
|
} |
|
|
|
|
|
return ossEntityList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static File multipartFileToFile(MultipartFile file ,String fileName) throws Exception { |
|
|
|
|
|
File toFile = null; |
|
|
|
|
|
if (file.equals("") || file.getSize() <= 0) { |
|
|
|
|
|
file = null; |
|
|
|
|
|
} else { |
|
|
|
|
|
InputStream ins = null; |
|
|
|
|
|
ins = file.getInputStream(); |
|
|
|
|
|
if(fileName != null && !"".equals(fileName)){ |
|
|
|
|
|
toFile = new File(fileName); |
|
|
|
|
|
}else{ |
|
|
|
|
|
toFile = new File(file.getOriginalFilename()); |
|
|
|
|
|
} |
|
|
|
|
|
inputStreamToFile(ins, toFile); |
|
|
|
|
|
ins.close(); |
|
|
|
|
|
} |
|
|
|
|
|
return toFile; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取流文件 |
|
|
|
|
|
private static void inputStreamToFile(InputStream ins, File file) { |
|
|
|
|
|
try { |
|
|
|
|
|
OutputStream os = new FileOutputStream(file); |
|
|
|
|
|
int bytesRead = 0; |
|
|
|
|
|
byte[] buffer = new byte[8192]; |
|
|
|
|
|
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { |
|
|
|
|
|
os.write(buffer, 0, bytesRead); |
|
|
|
|
|
} |
|
|
|
|
|
os.close(); |
|
|
|
|
|
ins.close(); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |