|
@@ -15,8 +15,6 @@ import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
import org.springblade.business.entity.TrialDeviceClassification;
|
|
import org.springblade.business.entity.TrialDeviceClassification;
|
|
import org.springblade.business.entity.TrialDeviceInfo;
|
|
import org.springblade.business.entity.TrialDeviceInfo;
|
|
-import org.springblade.business.entity.TrialMaterialMobilization;
|
|
|
|
-import org.springblade.business.entity.TrialSampleInfo;
|
|
|
|
import org.springblade.business.excel.TrialDeviceInfoExcel;
|
|
import org.springblade.business.excel.TrialDeviceInfoExcel;
|
|
import org.springblade.business.mapper.TrialDeviceClassificationMapper;
|
|
import org.springblade.business.mapper.TrialDeviceClassificationMapper;
|
|
import org.springblade.business.mapper.TrialDeviceInfoMapper;
|
|
import org.springblade.business.mapper.TrialDeviceInfoMapper;
|
|
@@ -24,6 +22,7 @@ import org.springblade.business.service.ITrialDeviceInfoService;
|
|
import org.springblade.business.utils.PDFUtil;
|
|
import org.springblade.business.utils.PDFUtil;
|
|
import org.springblade.business.utils.SystemUtils;
|
|
import org.springblade.business.utils.SystemUtils;
|
|
import org.springblade.business.vo.TrialDeviceInfoVO;
|
|
import org.springblade.business.vo.TrialDeviceInfoVO;
|
|
|
|
+import org.springblade.business.vo.TrialDeviceInfoVO3;
|
|
import org.springblade.business.wrapper.TrialDeviceInfoWarpper;
|
|
import org.springblade.business.wrapper.TrialDeviceInfoWarpper;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.mp.support.Condition;
|
|
import org.springblade.core.mp.support.Condition;
|
|
@@ -33,12 +32,9 @@ import org.springblade.core.tool.utils.DateUtil;
|
|
import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
-import org.springblade.system.user.entity.User;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.servlet.ServletOutputStream;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -57,7 +53,8 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
|
|
public boolean submit(TrialDeviceInfo obj) {
|
|
public boolean submit(TrialDeviceInfo obj) {
|
|
if (ObjectUtil.isNotEmpty(obj.getId())) {
|
|
if (ObjectUtil.isNotEmpty(obj.getId())) {
|
|
TrialDeviceInfo trialDeviceInfo = baseMapper.selectById(obj.getId());
|
|
TrialDeviceInfo trialDeviceInfo = baseMapper.selectById(obj.getId());
|
|
- if (!trialDeviceInfo.getLastCalibrationTime().equals(obj.getLastCalibrationTime())) {
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(trialDeviceInfo.getLastCalibrationTime()) && ObjectUtil.isNotEmpty(obj.getLastCalibrationTime())
|
|
|
|
+ && !trialDeviceInfo.getLastCalibrationTime().equals(obj.getLastCalibrationTime())) {
|
|
//如果修改了最近校验时间,那么每次编辑默认修改校验为0=否
|
|
//如果修改了最近校验时间,那么每次编辑默认修改校验为0=否
|
|
obj.setIsCalibration(0);
|
|
obj.setIsCalibration(0);
|
|
}
|
|
}
|
|
@@ -71,7 +68,10 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public IPage<TrialDeviceInfoVO> selectPage(IPage<TrialDeviceInfo> page, TrialDeviceInfoVO obj) {
|
|
|
|
|
|
+ public IPage<TrialDeviceInfoVO> mobilizationPage(IPage<TrialDeviceInfo> page, TrialDeviceInfoVO obj, Long contractId) {
|
|
|
|
+ //获取设备分类信息
|
|
|
|
+ List<TrialDeviceClassification> deviceClassifications = trialDeviceClassificationMapper.selectList(Wrappers.<TrialDeviceClassification>query().lambda().eq(TrialDeviceClassification::getContractId, contractId));
|
|
|
|
+
|
|
QueryWrapper<TrialDeviceInfo> queryWrapper = Condition.getQueryWrapper(obj);
|
|
QueryWrapper<TrialDeviceInfo> queryWrapper = Condition.getQueryWrapper(obj);
|
|
if (ObjectUtil.isNotEmpty(obj.getDeviceClassId())) {
|
|
if (ObjectUtil.isNotEmpty(obj.getDeviceClassId())) {
|
|
queryWrapper.lambda().eq(TrialDeviceInfo::getDeviceClassId, obj.getDeviceClassId());
|
|
queryWrapper.lambda().eq(TrialDeviceInfo::getDeviceClassId, obj.getDeviceClassId());
|
|
@@ -88,17 +88,24 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
|
|
}
|
|
}
|
|
if (StringUtils.isNotEmpty(obj.getStartTime()) && StringUtils.isNotEmpty(obj.getEndTime())) {
|
|
if (StringUtils.isNotEmpty(obj.getStartTime()) && StringUtils.isNotEmpty(obj.getEndTime())) {
|
|
String endTime = obj.getEndTime();
|
|
String endTime = obj.getEndTime();
|
|
- endTime = DateUtil.format(DateUtils.addDays(DateUtil.parse(endTime, "yyyy-MM-dd HH:mm:ss"), 1), "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
+ endTime = DateUtil.format(DateUtils.addDays(DateUtil.parse(endTime, "yyyy-MM-dd"), 1), "yyyy-MM-dd");
|
|
queryWrapper.lambda().between(TrialDeviceInfo::getCreateTime, obj.getStartTime(), endTime);
|
|
queryWrapper.lambda().between(TrialDeviceInfo::getCreateTime, obj.getStartTime(), endTime);
|
|
}
|
|
}
|
|
IPage<TrialDeviceInfo> pages = this.page(page, queryWrapper.lambda().orderBy(true, true, TrialDeviceInfo::getCreateTime));
|
|
IPage<TrialDeviceInfo> pages = this.page(page, queryWrapper.lambda().orderBy(true, true, TrialDeviceInfo::getCreateTime));
|
|
IPage<TrialDeviceInfoVO> trialDeviceInfoVOIPage = TrialDeviceInfoWarpper.build().pageVO(pages);
|
|
IPage<TrialDeviceInfoVO> trialDeviceInfoVOIPage = TrialDeviceInfoWarpper.build().pageVO(pages);
|
|
List<TrialDeviceInfoVO> records = trialDeviceInfoVOIPage.getRecords();
|
|
List<TrialDeviceInfoVO> records = trialDeviceInfoVOIPage.getRecords();
|
|
|
|
+ for (TrialDeviceInfoVO record : records) {
|
|
|
|
+ for (TrialDeviceClassification deviceClassification : deviceClassifications) {
|
|
|
|
+ if (record.getDeviceClassId().equals(deviceClassification.getId())) {
|
|
|
|
+ record.setDeviceClassName(deviceClassification.getClassName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return trialDeviceInfoVOIPage.setRecords(records);
|
|
return trialDeviceInfoVOIPage.setRecords(records);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public String printPdf(String ids, HttpServletResponse response) {
|
|
|
|
|
|
+ public String mobilizationPrintPdf(String ids, HttpServletResponse response, Long contractId) {
|
|
try {
|
|
try {
|
|
String fileName = java.net.URLEncoder.encode(DateUtil.time() + ".pdf", "UTF-8");
|
|
String fileName = java.net.URLEncoder.encode(DateUtil.time() + ".pdf", "UTF-8");
|
|
response.reset();
|
|
response.reset();
|
|
@@ -107,14 +114,16 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
|
|
//构造数据
|
|
//构造数据
|
|
List<TrialDeviceInfo> pdfData = baseMapper.selectBatchIds(Func.toLongList(ids));
|
|
List<TrialDeviceInfo> pdfData = baseMapper.selectBatchIds(Func.toLongList(ids));
|
|
//获取设备分类数据
|
|
//获取设备分类数据
|
|
- List<TrialDeviceClassification> deviceClassificationList = trialDeviceClassificationMapper.selectList(Wrappers.<TrialDeviceClassification>query().lambda());
|
|
|
|
|
|
+ List<TrialDeviceClassification> deviceClassificationList = trialDeviceClassificationMapper.selectList(Wrappers.<TrialDeviceClassification>query().lambda().eq(TrialDeviceClassification::getContractId, contractId));
|
|
|
|
|
|
//删除旧PDF
|
|
//删除旧PDF
|
|
List<String> pdfUrls = pdfData.stream().map(TrialDeviceInfo::getPdfUrl).distinct().collect(Collectors.toList());
|
|
List<String> pdfUrls = pdfData.stream().map(TrialDeviceInfo::getPdfUrl).distinct().collect(Collectors.toList());
|
|
for (String pdfUrl : pdfUrls) {
|
|
for (String pdfUrl : pdfUrls) {
|
|
//格式 https: //xxx.com//upload/20221101/xxx.pdf
|
|
//格式 https: //xxx.com//upload/20221101/xxx.pdf
|
|
- String pdfName = pdfUrl.split("//")[2].split("/")[2];
|
|
|
|
- newIOSSClient.removeFile(pdfName);
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(pdfUrl)) {
|
|
|
|
+ String pdfName = pdfUrl.split("//")[2].split("/")[2];
|
|
|
|
+ newIOSSClient.removeFile(pdfName);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//创建文档,设置页面大小、左右上下边距
|
|
//创建文档,设置页面大小、左右上下边距
|
|
@@ -156,7 +165,7 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
|
|
|
|
|
|
//标题
|
|
//标题
|
|
PdfPTable tableTitle = new PdfPTable(3);
|
|
PdfPTable tableTitle = new PdfPTable(3);
|
|
- //生成一个9列的表格
|
|
|
|
|
|
+ //生成一个18列的表格
|
|
PdfPTable table = new PdfPTable(18);
|
|
PdfPTable table = new PdfPTable(18);
|
|
|
|
|
|
//定义每个单元格的宽度
|
|
//定义每个单元格的宽度
|
|
@@ -191,27 +200,27 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
|
|
PDFUtil.createTableCell(s, textFont, table, lineHeight, colSpan);
|
|
PDFUtil.createTableCell(s, textFont, table, lineHeight, colSpan);
|
|
}
|
|
}
|
|
for (TrialDeviceInfo pdfDatum : pdfData) {
|
|
for (TrialDeviceInfo pdfDatum : pdfData) {
|
|
|
|
+ PDFUtil.createTableCell(String.valueOf(pdfDatum.getId()), textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(pdfDatum.getDeviceName(), textFont, table, lineHeight, colSpan);
|
|
for (TrialDeviceClassification classification : deviceClassificationList) {
|
|
for (TrialDeviceClassification classification : deviceClassificationList) {
|
|
- PDFUtil.createTableCell(String.valueOf(pdfDatum.getId()), textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getDeviceName(), textFont, table, lineHeight, colSpan);
|
|
|
|
if (classification.getId().equals(pdfDatum.getDeviceClassId())) {
|
|
if (classification.getId().equals(pdfDatum.getDeviceClassId())) {
|
|
PDFUtil.createTableCell(classification.getClassName(), textFont, table, lineHeight, colSpan);
|
|
PDFUtil.createTableCell(classification.getClassName(), textFont, table, lineHeight, colSpan);
|
|
}
|
|
}
|
|
- PDFUtil.createTableCell(pdfDatum.getDeviceNumber(), textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getDeviceModel(), textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getManufacturer(), textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getProductionDate().toString(), textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getFactoryNumber(), textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getEquipmentAcquisitionNumber(), textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getAccuracy(), textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getMeasuringRange(), textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getLastCalibrationTime().toString(), textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getStatus().equals(0) ? "已停用" : "启用中", textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getIsCalibration().equals(0) ? "否" : "是", textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getEquipmentAcquisitionNumber(), textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getManagerName(), textFont, table, lineHeight, colSpan);
|
|
|
|
- PDFUtil.createTableCell(pdfDatum.getRemarks(), textFont, table, lineHeight, colSpan);
|
|
|
|
}
|
|
}
|
|
|
|
+ PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getDeviceNumber()) ? pdfDatum.getDeviceNumber() : "", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getDeviceModel()) ? pdfDatum.getDeviceModel() : "", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getManufacturer()) ? pdfDatum.getManufacturer() : "", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getFactoryDate()) ? pdfDatum.getFactoryDate().toString() : "", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getFactoryNumber()) ? pdfDatum.getFactoryNumber() : "", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getEquipmentAcquisitionNumber()) ? pdfDatum.getEquipmentAcquisitionNumber() : "", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getAccuracy()) ? pdfDatum.getAccuracy() : "", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getMeasuringRange()) ? pdfDatum.getMeasuringRange() : "", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getLastCalibrationTime()) ? pdfDatum.getLastCalibrationTime().toString() : "", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(pdfDatum.getStatus().equals(0) ? "已停用" : "启用中", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(pdfDatum.getIsCalibration().equals(0) ? "否" : "是", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getEquipmentAcquisitionNumber()) ? pdfDatum.getEquipmentAcquisitionNumber() : "", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getManagerName()) ? pdfDatum.getManagerName() : "", textFont, table, lineHeight, colSpan);
|
|
|
|
+ PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getRemarks()) ? pdfDatum.getRemarks() : "", textFont, table, lineHeight, colSpan);
|
|
}
|
|
}
|
|
|
|
|
|
document.add(table);
|
|
document.add(table);
|
|
@@ -251,8 +260,8 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public boolean saveBatchDeviceInfo(List<TrialDeviceInfoExcel> list) {
|
|
|
|
- List<TrialDeviceClassification> deviceClassifications = trialDeviceClassificationMapper.selectList(Wrappers.<TrialDeviceClassification>query().lambda());
|
|
|
|
|
|
+ public boolean saveBatchDeviceInfo(List<TrialDeviceInfoExcel> list, Long contractId) {
|
|
|
|
+ List<TrialDeviceClassification> deviceClassifications = trialDeviceClassificationMapper.selectList(Wrappers.<TrialDeviceClassification>query().lambda().eq(TrialDeviceClassification::getContractId, contractId));
|
|
List<TrialDeviceInfo> listData = new ArrayList<>();
|
|
List<TrialDeviceInfo> listData = new ArrayList<>();
|
|
for (TrialDeviceInfoExcel trialDeviceInfoExcel : list) {
|
|
for (TrialDeviceInfoExcel trialDeviceInfoExcel : list) {
|
|
for (TrialDeviceClassification deviceClassification : deviceClassifications) {
|
|
for (TrialDeviceClassification deviceClassification : deviceClassifications) {
|
|
@@ -265,8 +274,13 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- this.saveBatch(listData);
|
|
|
|
- return true;
|
|
|
|
|
|
+ return this.saveBatch(listData, 1000);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<TrialDeviceInfoVO3> useDeviceList(Long deviceClassId) {
|
|
|
|
+ List<TrialDeviceInfo> deviceInfos = baseMapper.selectList(Wrappers.<TrialDeviceInfo>query().lambda().eq(TrialDeviceInfo::getDeviceClassId, deviceClassId));
|
|
|
|
+ return BeanUtil.copyProperties(deviceInfos, TrialDeviceInfoVO3.class);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|