|
@@ -45,6 +45,7 @@ import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.text.DateFormat;
|
|
@@ -61,8 +62,7 @@ import java.util.*;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/sems/thickness")
|
|
|
-public class TMeasureThicknessController extends BaseController
|
|
|
-{
|
|
|
+public class TMeasureThicknessController extends BaseController {
|
|
|
@Autowired
|
|
|
private ITMeasureThicknessService tMeasureThicknessService;
|
|
|
@Autowired
|
|
@@ -74,6 +74,7 @@ public class TMeasureThicknessController extends BaseController
|
|
|
|
|
|
// 美标(ASME)与国标B系列外径对照表(单位:mm)
|
|
|
private static final Map<Double, Double> INCH_TO_MM_MAP = new HashMap<>();
|
|
|
+
|
|
|
static {
|
|
|
// 基础尺寸(0.5"~4")
|
|
|
INCH_TO_MM_MAP.put(0.5, 21.3); // 1/2英寸 → 21.3mm(国标B系列与ASME一致)[1,2](@ref)
|
|
@@ -83,7 +84,7 @@ public class TMeasureThicknessController extends BaseController
|
|
|
INCH_TO_MM_MAP.put(2.0, 57.0); // 2英寸 → 国标B系列57.0mm(ASME为60.3mm)[2,3](@ref)
|
|
|
INCH_TO_MM_MAP.put(3.0, 88.9); // 3英寸 → 88.9mm(国标B系列与ASME一致)[1,2](@ref)
|
|
|
INCH_TO_MM_MAP.put(4.0, 114.3); // 4英寸 → 114.3mm(国标B系列与ASME一致)
|
|
|
-
|
|
|
+ INCH_TO_MM_MAP.put(5.0, 141.3); // 5英寸
|
|
|
// 扩展尺寸(6"~20")
|
|
|
INCH_TO_MM_MAP.put(6.0, 168.3); // 6英寸 → 168.3mm(国标B系列与ASME一致)[2](@ref)
|
|
|
INCH_TO_MM_MAP.put(8.0, 219.1); // 8英寸 → 219.1mm(国标B系列与ASME一致)[2](@ref)
|
|
@@ -96,13 +97,13 @@ public class TMeasureThicknessController extends BaseController
|
|
|
}
|
|
|
|
|
|
private final Long alarmtype = 1080L;//特种设备预警ID
|
|
|
+
|
|
|
/**
|
|
|
* 查询定点测厚列表
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('sems:thickness:list')")
|
|
|
@GetMapping("/list")
|
|
|
- public TableDataInfo list(TMeasureThickness tMeasureThickness)
|
|
|
- {
|
|
|
+ public TableDataInfo list(TMeasureThickness tMeasureThickness) {
|
|
|
logger.info(JSON.toJSONString(tMeasureThickness));
|
|
|
startPage();
|
|
|
List<TMeasureThickness> list = tMeasureThicknessService.selectTMeasureThicknessList(tMeasureThickness);
|
|
@@ -122,22 +123,22 @@ public class TMeasureThicknessController extends BaseController
|
|
|
// nextMeasureDate.setTime(dat);
|
|
|
// java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd");
|
|
|
// m.setNextMeasureDate(format.format(nextMeasureDate.getTime()));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
m.setFirstMeasureDate(null);
|
|
|
m.setNewMeasureDate(null);
|
|
|
m.setNextMeasureDate(null);
|
|
|
}
|
|
|
//寿命预警
|
|
|
if (m.getNextWarnDate() != null && !StringUtils.isEmpty(m.getEstRemain())) {
|
|
|
- int day = this.formatDate(m.getNextWarnDate(),new Date());
|
|
|
- BigDecimal remain = new BigDecimal(m.getEstRemain()).multiply(new BigDecimal("365")).setScale(4,BigDecimal.ROUND_HALF_DOWN);
|
|
|
- logger.info(day +"::::" + remain);
|
|
|
- if (remain.compareTo(new BigDecimal(day)) == -1) {
|
|
|
+ int day = this.formatDate(m.getNextWarnDate(), new Date());
|
|
|
+ BigDecimal remain = new BigDecimal(m.getEstRemain()).multiply(new BigDecimal("365")).setScale(4, BigDecimal.ROUND_HALF_DOWN);
|
|
|
+ logger.info(day + "::::" + remain);
|
|
|
+ if (remain.compareTo(new BigDecimal(day)) == -1) {
|
|
|
m.setWarnFlag(1);
|
|
|
- }else {
|
|
|
- m.setWarnFlag(0);
|
|
|
- }
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
+ m.setWarnFlag(0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
m.setWarnFlag(0);
|
|
|
}
|
|
|
}
|
|
@@ -150,12 +151,11 @@ public class TMeasureThicknessController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('sems:thickness:add')")
|
|
|
@Log(title = "侧厚批量导入", businessType = BusinessType.INSERT)
|
|
|
@PostMapping("/importData")
|
|
|
- public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException
|
|
|
- {
|
|
|
+ public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException {
|
|
|
//获取操作人员ID
|
|
|
Long userId = getUserId();
|
|
|
//报错行数统计
|
|
|
- List<Integer> failRow =new ArrayList<Integer>();
|
|
|
+ List<Integer> failRow = new ArrayList<Integer>();
|
|
|
Workbook workbook = ExcelUtils.getWorkBook(file);
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
|
List<TMeasureThickness> list = new ArrayList<TMeasureThickness>();
|
|
@@ -188,7 +188,7 @@ public class TMeasureThicknessController extends BaseController
|
|
|
entity.setPosition(cellValue);//测厚部位CML
|
|
|
} else if (j == 5) {
|
|
|
entity.setLoopNo(cellValue);//回路编号
|
|
|
- }else if (j == 6) {
|
|
|
+ } else if (j == 6) {
|
|
|
entity.setMeasureNo(cellValue);//检测编号
|
|
|
} else if (j == 7) {
|
|
|
entity.setEquipmentName(cellValue);//设备/管线名称
|
|
@@ -208,9 +208,9 @@ public class TMeasureThicknessController extends BaseController
|
|
|
if (cellValue.length() > 3) {//下次测厚日期
|
|
|
entity.setNextWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
}
|
|
|
- } else if (j == 15) {
|
|
|
+ } else if (j == 15) {
|
|
|
entity.setInspectionMethod(cellValue);//检测方法
|
|
|
- } else if (j == 16) {
|
|
|
+ } else if (j == 16) {
|
|
|
entity.setCorAllowance(cellValue);//腐蚀裕度(mm)
|
|
|
} else if (j == 17) {
|
|
|
entity.setOriginalThickness(cellValue);//原始壁厚(mm)
|
|
@@ -224,38 +224,38 @@ public class TMeasureThicknessController extends BaseController
|
|
|
entity.setFlowRate(cellValue);//流速(m/s)
|
|
|
} else if (j == 22) {
|
|
|
//温度(℃)
|
|
|
- entity.setTemperature(cellValue);
|
|
|
+ entity.setTemperature(cellValue);
|
|
|
} else if (j == 23) {
|
|
|
//腐蚀类型
|
|
|
entity.setCorrosionType(cellValue);
|
|
|
} else if (j == 24) {
|
|
|
entity.setAnalysis(cellValue);//原因分析
|
|
|
- }else if (j == 25) {
|
|
|
+ } else if (j == 25) {
|
|
|
entity.setMethodCause(cellValue);//治理方法及依据
|
|
|
} else if (j == 26) {
|
|
|
entity.setEffectTracing(cellValue); //效果跟踪
|
|
|
- }else if (j == 27) {
|
|
|
+ } else if (j == 27) {
|
|
|
entity.setRaiser(cellValue);//提出人
|
|
|
- }else if (j == 28) {
|
|
|
+ } else if (j == 28) {
|
|
|
if (cellValue.length() > 3) {//提出时间
|
|
|
entity.setRaiserDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
}
|
|
|
- }else if (j == 29) {
|
|
|
+ } else if (j == 29) {
|
|
|
entity.setOtherContent(cellValue);//其他检测方法内容
|
|
|
- }else if (j == 30) {
|
|
|
+ } else if (j == 30) {
|
|
|
entity.setRecorder(cellValue);//记录人
|
|
|
- }else if (j == 31) {
|
|
|
+ } else if (j == 31) {
|
|
|
if (cellValue.length() > 3) {//记录时间
|
|
|
entity.setRecorderDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
}
|
|
|
- }else if (j == 32) {
|
|
|
+ } else if (j == 32) {
|
|
|
entity.setRemarks(cellValue);//备注
|
|
|
}
|
|
|
}
|
|
|
entity.setCreateBy(userId.toString());
|
|
|
logger.info("entity:" + entity);
|
|
|
list.add(entity);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
failNumber++;
|
|
|
logger.info("e:" + JSON.toJSONString(e));
|
|
|
failRow.add(i + 1);
|
|
@@ -269,16 +269,16 @@ public class TMeasureThicknessController extends BaseController
|
|
|
try {
|
|
|
tMeasureThicknessService.insertTMeasureThickness(t);
|
|
|
successNumber++;
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
failNumber++;
|
|
|
logger.info("e:" + e);
|
|
|
failRow.add(failNum + 1);
|
|
|
}
|
|
|
}
|
|
|
logger.info("list:" + JSON.toJSONString(list));
|
|
|
- logger.info("successNumber:" +String.valueOf(successNumber));
|
|
|
- logger.info("failNumber:" +String.valueOf(failNumber));
|
|
|
- logger.info("failRow:" +String.valueOf(failRow));
|
|
|
+ logger.info("successNumber:" + String.valueOf(successNumber));
|
|
|
+ logger.info("failNumber:" + String.valueOf(failNumber));
|
|
|
+ logger.info("failRow:" + String.valueOf(failRow));
|
|
|
return AjaxResult.success(String.valueOf(successNumber), failRow);
|
|
|
}
|
|
|
|
|
@@ -288,8 +288,7 @@ public class TMeasureThicknessController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('sems:thickness:export')")
|
|
|
@Log(title = "定点测厚", businessType = BusinessType.EXPORT)
|
|
|
@GetMapping("/export")
|
|
|
- public AjaxResult export(TMeasureThickness tMeasureThickness)
|
|
|
- {
|
|
|
+ public AjaxResult export(TMeasureThickness tMeasureThickness) {
|
|
|
List<TMeasureThickness> list = tMeasureThicknessService.selectTMeasureThicknessList(tMeasureThickness);
|
|
|
ExcelUtil<TMeasureThickness> util = new ExcelUtil<TMeasureThickness>(TMeasureThickness.class);
|
|
|
return util.exportExcel(list, "thickness");
|
|
@@ -300,8 +299,7 @@ public class TMeasureThicknessController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('sems:thickness:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
- {
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
//生成图表
|
|
|
String chartUrl = "/profile/" + this.getRecordUrl(id.toString());
|
|
|
TMeasureThickness t = tMeasureThicknessService.selectTMeasureThicknessById(id);
|
|
@@ -315,8 +313,7 @@ public class TMeasureThicknessController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('sems:thickness:add')")
|
|
|
@Log(title = "定点测厚", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody TMeasureThickness tMeasureThickness)
|
|
|
- {
|
|
|
+ public AjaxResult add(@RequestBody TMeasureThickness tMeasureThickness) {
|
|
|
return toAjax(tMeasureThicknessService.insertTMeasureThickness(tMeasureThickness));
|
|
|
}
|
|
|
|
|
@@ -326,8 +323,8 @@ public class TMeasureThicknessController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('sems:thickness:edit')")
|
|
|
@Log(title = "定点测厚", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@RequestBody TMeasureThickness tMeasureThickness)
|
|
|
- {
|
|
|
+ public AjaxResult edit(@RequestBody TMeasureThickness tMeasureThickness) {
|
|
|
+ tMeasureThickness.setThicknessMin(calculateTsd(tMeasureThickness));
|
|
|
return toAjax(tMeasureThicknessService.updateTMeasureThickness(tMeasureThickness));
|
|
|
}
|
|
|
|
|
@@ -336,9 +333,8 @@ public class TMeasureThicknessController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('sems:thickness:remove')")
|
|
|
@Log(title = "定点测厚", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{ids}")
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
- {
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(tMeasureThicknessService.deleteTMeasureThicknessByIds(ids));
|
|
|
}
|
|
|
|
|
@@ -347,10 +343,8 @@ public class TMeasureThicknessController extends BaseController
|
|
|
*/
|
|
|
@Log(title = "定点测厚图片上传", businessType = BusinessType.UPDATE)
|
|
|
@PostMapping("/uploadFile")
|
|
|
- public AjaxResult uploadFile(@RequestParam("file") MultipartFile file) throws IOException
|
|
|
- {
|
|
|
- if (!file.isEmpty())
|
|
|
- {
|
|
|
+ public AjaxResult uploadFile(@RequestParam("file") MultipartFile file) throws IOException {
|
|
|
+ if (!file.isEmpty()) {
|
|
|
String avatar = FileUploadUtils.upload(RuoYiConfig.getFilePath("/thickness"), file);
|
|
|
return AjaxResult.success(avatar);
|
|
|
}
|
|
@@ -360,7 +354,7 @@ public class TMeasureThicknessController extends BaseController
|
|
|
|
|
|
@RequestMapping("/measure/exportPDF")
|
|
|
public String measure(@RequestParam String id, HttpServletRequest request, HttpServletResponse response) {
|
|
|
- OutputStream out= null;
|
|
|
+ OutputStream out = null;
|
|
|
try {
|
|
|
getRecordUrl(id);
|
|
|
out = response.getOutputStream();
|
|
@@ -379,45 +373,55 @@ public class TMeasureThicknessController extends BaseController
|
|
|
String[] inspectionMethod = measureThicknessEntity.getInspectionMethod().split(",");
|
|
|
logger.info("inspectionMethod:" + inspectionMethod);
|
|
|
for (String m : inspectionMethod) {
|
|
|
- if (m.equals("1")){ measureThicknessEntity.setMethodUT(true); }
|
|
|
- if (m.equals("2")){ measureThicknessEntity.setMethodPEC(true); }
|
|
|
- if (m.equals("3")){ measureThicknessEntity.setMethodRT(true); }
|
|
|
- if (m.equals("4")){ measureThicknessEntity.setMethodEMAT(true); }
|
|
|
- if (m.equals("5")){ measureThicknessEntity.setMethodOther(true); }
|
|
|
+ if (m.equals("1")) {
|
|
|
+ measureThicknessEntity.setMethodUT(true);
|
|
|
+ }
|
|
|
+ if (m.equals("2")) {
|
|
|
+ measureThicknessEntity.setMethodPEC(true);
|
|
|
+ }
|
|
|
+ if (m.equals("3")) {
|
|
|
+ measureThicknessEntity.setMethodRT(true);
|
|
|
+ }
|
|
|
+ if (m.equals("4")) {
|
|
|
+ measureThicknessEntity.setMethodEMAT(true);
|
|
|
+ }
|
|
|
+ if (m.equals("5")) {
|
|
|
+ measureThicknessEntity.setMethodOther(true);
|
|
|
+ }
|
|
|
}
|
|
|
map.put("measure", measureThicknessEntity);
|
|
|
logger.info("measure:" + measureThicknessEntity);
|
|
|
- if(StringUtils.isNotEmpty(measureThicknessEntity.getPhoto())){
|
|
|
- String[] photos = measureThicknessEntity.getPhoto().split(",");
|
|
|
+ if (StringUtils.isNotEmpty(measureThicknessEntity.getPhoto())) {
|
|
|
+ String[] photos = measureThicknessEntity.getPhoto().split(",");
|
|
|
if (photos.length == 1) {
|
|
|
- map.put("photo1", photos[0].replaceAll("/profile/",""));
|
|
|
- }else if (photos.length == 2) {
|
|
|
- map.put("photo1", photos[0].replaceAll("/profile/",""));
|
|
|
- map.put("photo2", photos[1].replaceAll("/profile/",""));
|
|
|
- }else if (photos.length == 3) {
|
|
|
- map.put("photo1", photos[0].replaceAll("/profile/",""));
|
|
|
- map.put("photo2", photos[1].replaceAll("/profile/",""));
|
|
|
- map.put("photo3", photos[2].replaceAll("/profile/",""));
|
|
|
+ map.put("photo1", photos[0].replaceAll("/profile/", ""));
|
|
|
+ } else if (photos.length == 2) {
|
|
|
+ map.put("photo1", photos[0].replaceAll("/profile/", ""));
|
|
|
+ map.put("photo2", photos[1].replaceAll("/profile/", ""));
|
|
|
+ } else if (photos.length == 3) {
|
|
|
+ map.put("photo1", photos[0].replaceAll("/profile/", ""));
|
|
|
+ map.put("photo2", photos[1].replaceAll("/profile/", ""));
|
|
|
+ map.put("photo3", photos[2].replaceAll("/profile/", ""));
|
|
|
}
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(measureThicknessEntity.getLocationUrl())){
|
|
|
- String[] locationUrls = measureThicknessEntity.getLocationUrl().split(",");
|
|
|
+ if (StringUtils.isNotEmpty(measureThicknessEntity.getLocationUrl())) {
|
|
|
+ String[] locationUrls = measureThicknessEntity.getLocationUrl().split(",");
|
|
|
if (locationUrls.length == 1) {
|
|
|
- map.put("locationUrl1", locationUrls[0].replaceAll("/profile/",""));
|
|
|
- }else if (locationUrls.length == 2) {
|
|
|
- map.put("locationUrl1", locationUrls[0].replaceAll("/profile/",""));
|
|
|
- map.put("locationUrl2", locationUrls[1].replaceAll("/profile/",""));
|
|
|
+ map.put("locationUrl1", locationUrls[0].replaceAll("/profile/", ""));
|
|
|
+ } else if (locationUrls.length == 2) {
|
|
|
+ map.put("locationUrl1", locationUrls[0].replaceAll("/profile/", ""));
|
|
|
+ map.put("locationUrl2", locationUrls[1].replaceAll("/profile/", ""));
|
|
|
logger.info(locationUrls[0]);
|
|
|
- }else if (locationUrls.length == 3) {
|
|
|
- map.put("locationUrl1", locationUrls[0].replaceAll("/profile/",""));
|
|
|
- map.put("locationUrl2", locationUrls[1].replaceAll("/profile/",""));
|
|
|
- map.put("locationUrl3", locationUrls[2].replaceAll("/profile/",""));
|
|
|
+ } else if (locationUrls.length == 3) {
|
|
|
+ map.put("locationUrl1", locationUrls[0].replaceAll("/profile/", ""));
|
|
|
+ map.put("locationUrl2", locationUrls[1].replaceAll("/profile/", ""));
|
|
|
+ map.put("locationUrl3", locationUrls[2].replaceAll("/profile/", ""));
|
|
|
}
|
|
|
}
|
|
|
- //测量记录分行
|
|
|
- List<TMeasureRecord> measureRecords = tMeasureRecordService.queryRecords(id);
|
|
|
- List<List<TMeasureRecord>> result = new ArrayList<List<TMeasureRecord>>();
|
|
|
- int sourceSize = measureRecords.size();
|
|
|
+ //测量记录分行
|
|
|
+ List<TMeasureRecord> measureRecords = tMeasureRecordService.queryRecords(id);
|
|
|
+ List<List<TMeasureRecord>> result = new ArrayList<List<TMeasureRecord>>();
|
|
|
+ int sourceSize = measureRecords.size();
|
|
|
int size = (measureRecords.size() / 7) + 1;
|
|
|
if (measureRecords.size() % 7 == 0) {
|
|
|
size = size - 1;
|
|
@@ -440,14 +444,14 @@ public class TMeasureThicknessController extends BaseController
|
|
|
}
|
|
|
map.put("result", result);
|
|
|
logger.info("result:" + result);
|
|
|
- String name = measureThicknessEntity.getPlantCode() +"-" +measureThicknessEntity.getTagno() + "-" + measureThicknessEntity.getPosition();
|
|
|
- PDFTemplateUtil.exportPdf("measureFMaker.ftl", name + ".pdf","file:"+RuoYiConfig.getProfile(), map, response);
|
|
|
+ String name = measureThicknessEntity.getPlantCode() + "-" + measureThicknessEntity.getTagno() + "-" + measureThicknessEntity.getPosition();
|
|
|
+ PDFTemplateUtil.exportPdf("measureFMaker.ftl", name + ".pdf", "file:" + RuoYiConfig.getProfile(), map, response);
|
|
|
// PDFTemplateUtil.exportPdf("measureFMaker.ftl", name + ".pdf",RuoYiConfig.getProfile(), map, response);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- }finally {
|
|
|
- if(out!=null)
|
|
|
+ } finally {
|
|
|
+ if (out != null)
|
|
|
try {
|
|
|
out.close();
|
|
|
} catch (IOException e) {
|
|
@@ -457,7 +461,7 @@ public class TMeasureThicknessController extends BaseController
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public String getRecordUrl(String id){
|
|
|
+ public String getRecordUrl(String id) {
|
|
|
try {
|
|
|
TMeasureThickness measureThicknessEntity = tMeasureThicknessService.selectTMeasureThicknessById(Long.parseLong(id));
|
|
|
List<TMeasureRecord> measureRecords = tMeasureRecordService.queryRecords(id);
|
|
@@ -465,24 +469,24 @@ public class TMeasureThicknessController extends BaseController
|
|
|
//种类数据集
|
|
|
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
- for (TMeasureRecord t: measureRecords
|
|
|
+ for (TMeasureRecord t : measureRecords
|
|
|
) {
|
|
|
- dataset.addValue(t.getMeasureValue() , "数值Value" , sdf.format(t.getMeasureDate()));
|
|
|
- if (measureThicknessEntity.getThicknessMin() != null){
|
|
|
- dataset.addValue(Double.parseDouble(measureThicknessEntity.getThicknessMin()) , "最小允许壁厚" , sdf.format(t.getMeasureDate()));
|
|
|
+ dataset.addValue(t.getMeasureValue(), "数值Value", sdf.format(t.getMeasureDate()));
|
|
|
+ if (measureThicknessEntity.getThicknessMin() != null) {
|
|
|
+ dataset.addValue(Double.parseDouble(measureThicknessEntity.getThicknessMin()), "最小允许壁厚", sdf.format(t.getMeasureDate()));
|
|
|
}
|
|
|
}
|
|
|
- String url = RuoYiConfig.getProfile() + "/" + id +".jpg";
|
|
|
- ChartUtil.createLinePort("" , dataset ,"" ,"" , url ) ;
|
|
|
+ String url = RuoYiConfig.getProfile() + "/" + id + ".jpg";
|
|
|
+ ChartUtil.createLinePort("", dataset, "", "", url);
|
|
|
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
logger.error("生成图片错误");
|
|
|
logger.error(JSON.toJSONString(e));
|
|
|
}
|
|
|
- return id +".jpg";
|
|
|
+ return id + ".jpg";
|
|
|
}
|
|
|
|
|
|
- private int formatDate(Date nowDate, Date sqlDate){
|
|
|
+ private int formatDate(Date nowDate, Date sqlDate) {
|
|
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String newDate = df.format(nowDate);
|
|
|
String sqlDate1 = df.format(sqlDate);
|
|
@@ -492,11 +496,12 @@ public class TMeasureThicknessController extends BaseController
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- Long time = nowDate.getTime();
|
|
|
- Long time2 = sqlDate.getTime();
|
|
|
- int day = (int) ((time - time2) / (24*3600*1000));
|
|
|
+ Long time = nowDate.getTime();
|
|
|
+ Long time2 = sqlDate.getTime();
|
|
|
+ int day = (int) ((time - time2) / (24 * 3600 * 1000));
|
|
|
return day;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @param id
|
|
|
* @return
|
|
@@ -520,7 +525,7 @@ public class TMeasureThicknessController extends BaseController
|
|
|
//根据ID查询并生成
|
|
|
TMeasureThickness t = tMeasureThicknessService.selectTMeasureThicknessById(id);
|
|
|
String url = this.createcheck(t);
|
|
|
- if (StringUtils.isNotEmpty(t.getCheckUrl()) ) {
|
|
|
+ if (StringUtils.isNotEmpty(t.getCheckUrl())) {
|
|
|
//合并PDF
|
|
|
logger.info("url:" + url);
|
|
|
// 将路径字符串转换为Path对象
|
|
@@ -528,13 +533,13 @@ public class TMeasureThicknessController extends BaseController
|
|
|
// 获取文件名
|
|
|
String fileName = path.getFileName().toString();
|
|
|
fileName = officeConvertController.wordTransPdf(url);
|
|
|
- String filePathOne = RuoYiConfig.getProfile() + "/" + fileName.replace("/profile","");
|
|
|
- String filePathTwo =RuoYiConfig.getProfile() + "/" + t.getCheckUrl().replace("/profile","");
|
|
|
- String newPdfPath = "sems/measure/" + t.getId() + ".pdf" ;
|
|
|
+ String filePathOne = RuoYiConfig.getProfile() + "/" + fileName.replace("/profile", "");
|
|
|
+ String filePathTwo = RuoYiConfig.getProfile() + "/" + t.getCheckUrl().replace("/profile", "");
|
|
|
+ String newPdfPath = "sems/measure/" + t.getId() + ".pdf";
|
|
|
logger.info("newPdfPath:" + newPdfPath);
|
|
|
logger.info("filePathOne:" + filePathOne);
|
|
|
logger.info("filePathTwo:" + filePathTwo);
|
|
|
- PDFUtil.mergeTwoPdfs(filePathOne ,filePathTwo,RuoYiConfig.getProfile() + "/" + newPdfPath);
|
|
|
+ PDFUtil.mergeTwoPdfs(filePathOne, filePathTwo, RuoYiConfig.getProfile() + "/" + newPdfPath);
|
|
|
return "/profile/" + newPdfPath;
|
|
|
}
|
|
|
return url;
|
|
@@ -552,7 +557,7 @@ public class TMeasureThicknessController extends BaseController
|
|
|
// 生成word的路径
|
|
|
String fileDir = RuoYiConfig.getProfile() + "/" + "sems/measure";
|
|
|
// 生成word的文件名称
|
|
|
- String fileName = tMeasureThickness.getPlantCode()+ "_" +tMeasureThickness.getId() + ".docx";
|
|
|
+ String fileName = tMeasureThickness.getPlantCode() + "_" + tMeasureThickness.getId() + ".docx";
|
|
|
String wordPath = this.createWord(templatePath, fileDir, fileName, params);
|
|
|
return wordPath;
|
|
|
}
|
|
@@ -618,21 +623,21 @@ public class TMeasureThicknessController extends BaseController
|
|
|
params.put("corrosion3", Pictures.ofLocal(fileName(pArr[2])).size(240, 240).create());
|
|
|
}
|
|
|
}
|
|
|
- String trendUrl = "/" + getRecordUrl(thickness.getId()+"");
|
|
|
+ String trendUrl = "/" + getRecordUrl(thickness.getId() + "");
|
|
|
logger.info("trendUrl:" + trendUrl);
|
|
|
params.put("trend", Pictures.ofLocal(fileName(trendUrl)).size(600, 300).create());
|
|
|
|
|
|
//测量记录分行
|
|
|
- List<TMeasureRecord> measureRecords = tMeasureRecordService.queryRecords(thickness.getId()+"");
|
|
|
+ List<TMeasureRecord> measureRecords = tMeasureRecordService.queryRecords(thickness.getId() + "");
|
|
|
RowRenderData[] rowList = new RowRenderData[measureRecords.size() + 1];
|
|
|
rowList[0] = Rows.of("日期Date", "数值Value").textColor("FFFFFF")
|
|
|
.bgColor("4472C4").center().create();
|
|
|
List rows = new ArrayList();
|
|
|
int i = 0;
|
|
|
- for (TMeasureRecord m: measureRecords
|
|
|
- ) {
|
|
|
+ for (TMeasureRecord m : measureRecords
|
|
|
+ ) {
|
|
|
i++;
|
|
|
- rowList[i] = Rows.create(DateUtils.dateTime(m.getMeasureDate()),m.getMeasureValue()+"");
|
|
|
+ rowList[i] = Rows.create(DateUtils.dateTime(m.getMeasureDate()), m.getMeasureValue() + "");
|
|
|
}
|
|
|
|
|
|
params.put("table", Tables.of(rowList).create());
|
|
@@ -688,6 +693,7 @@ public class TMeasureThicknessController extends BaseController
|
|
|
|
|
|
/**
|
|
|
* 将字符串转换为 double 数值,支持多种格式(如逗号/小数点分隔符、千位分隔符等)
|
|
|
+ *
|
|
|
* @param valueStr 输入的字符串(如 "2.5", "1,200.75", "3,14")
|
|
|
* @return 转换后的 double 数值
|
|
|
* @throws ParseException 如果无法解析字符串
|
|
@@ -704,9 +710,10 @@ public class TMeasureThicknessController extends BaseController
|
|
|
|
|
|
/**
|
|
|
* 将带单位的英寸字符串转换为国标B系列外径(毫米)
|
|
|
+ *
|
|
|
* @param input 输入字符串(如 "6\"", "2.5in", "3.14inch")
|
|
|
* @return 国标B系列对应的外径(毫米)
|
|
|
- * @throws ParseException 如果输入格式无法解析
|
|
|
+ * @throws ParseException 如果输入格式无法解析
|
|
|
* @throws IllegalArgumentException 如果尺寸未在对照表中定义
|
|
|
*/
|
|
|
public static double convertInchStringToMillimeters(String input) throws ParseException, IllegalArgumentException {
|
|
@@ -729,27 +736,87 @@ public class TMeasureThicknessController extends BaseController
|
|
|
/**
|
|
|
* 计算管道壁厚的通用方法(输入参数均为 String 类型)
|
|
|
*/
|
|
|
- public double calculateTsd(TMeasureThickness thickness)
|
|
|
- throws ParseException {
|
|
|
- // 转换所有参数为 double
|
|
|
- double p = parseStringToDouble(thickness.getDesPressure());
|
|
|
- double d0 = convertInchStringToMillimeters(thickness.getSpecification());
|
|
|
- double ej = 1;
|
|
|
- double y = 0.4;
|
|
|
-
|
|
|
- TMeasureStress stress = tMeasureStressMapper.selectTMeasureStressByName(thickness.getMaterial());
|
|
|
- double c2 = 1.5;
|
|
|
- if (stress.getIsSteel() == 1) {
|
|
|
- c2 = 1 ;
|
|
|
- }
|
|
|
+ public String calculateTsd(TMeasureThickness thickness) {
|
|
|
+ try {
|
|
|
+ // 转换所有参数为 double
|
|
|
+ double p = 0;
|
|
|
|
|
|
- double sT = 0;
|
|
|
+ p = parseStringToDouble(thickness.getDesPressure());
|
|
|
|
|
|
+ double d0 = convertInchStringToMillimeters(thickness.getSpecification());
|
|
|
+ double ej = 1;
|
|
|
+ double y = 0.4;
|
|
|
|
|
|
- // 计算壁厚公式
|
|
|
- double numerator = p * d0;
|
|
|
- double denominator = 2 * (sT * ej + p * y);
|
|
|
- return (numerator / denominator) + c2;
|
|
|
+ TMeasureStress stress = tMeasureStressMapper.selectTMeasureStressByName(thickness.getMaterial());
|
|
|
+ double c2 = 1.5;
|
|
|
+ if (stress.getIsSteel() == 1) {
|
|
|
+ c2 = 1;
|
|
|
+ }
|
|
|
+ String stStress = "";
|
|
|
+ double desTemp = parseStringToDouble(thickness.getDesTemp());
|
|
|
+ if (desTemp <= 40) {
|
|
|
+ stStress = stress.getC40();
|
|
|
+ } else if (desTemp <= 65) {
|
|
|
+ stStress = stress.getC65();
|
|
|
+ } else if (desTemp <= 100) {
|
|
|
+ stStress = stress.getC100();
|
|
|
+ } else if (desTemp <= 125) {
|
|
|
+ stStress = stress.getC125();
|
|
|
+ } else if (desTemp <= 150) {
|
|
|
+ stStress = stress.getC150();
|
|
|
+ } else if (desTemp <= 175) {
|
|
|
+ stStress = stress.getC175();
|
|
|
+ } else if (desTemp <= 200) {
|
|
|
+ stStress = stress.getC200();
|
|
|
+ } else if (desTemp <= 225) {
|
|
|
+ stStress = stress.getC225();
|
|
|
+ } else if (desTemp <= 250) {
|
|
|
+ stStress = stress.getC250();
|
|
|
+ } else if (desTemp <= 275) {
|
|
|
+ stStress = stress.getC275();
|
|
|
+ } else if (desTemp <= 300) {
|
|
|
+ stStress = stress.getC300();
|
|
|
+ } else if (desTemp <= 325) {
|
|
|
+ stStress = stress.getC325();
|
|
|
+ } else if (desTemp <= 350) {
|
|
|
+ stStress = stress.getC350();
|
|
|
+ } else if (desTemp <= 375) {
|
|
|
+ stStress = stress.getC375();
|
|
|
+ } else if (desTemp <= 400) {
|
|
|
+ stStress = stress.getC400();
|
|
|
+ } else if (desTemp <= 425) {
|
|
|
+ stStress = stress.getC425();
|
|
|
+ } else if (desTemp <= 450) {
|
|
|
+ stStress = stress.getC450(); // 允许返回 null
|
|
|
+ } else if (desTemp <= 475) {
|
|
|
+ stStress = stress.getC475(); // 允许返回 null
|
|
|
+ } else if (desTemp <= 500) {
|
|
|
+ stStress = stress.getC500(); // 允许返回 null
|
|
|
+ } else if (desTemp <= 525) {
|
|
|
+ stStress = stress.getC525(); // 允许返回 null
|
|
|
+ } else if (desTemp <= 550) {
|
|
|
+ stStress = stress.getC550(); // 允许返回 null
|
|
|
+ } else if (desTemp <= 575) {
|
|
|
+ stStress = stress.getC575(); // 允许返回 null
|
|
|
+ } else if (desTemp <= 600) {
|
|
|
+ stStress = stress.getC600(); // 允许返回 null
|
|
|
+ } else {
|
|
|
+ stStress = stress.getC600(); // 超过 600 仍用 c600
|
|
|
+ }
|
|
|
+
|
|
|
+ double sT = parseStringToDouble(stStress);
|
|
|
+
|
|
|
+ // 计算壁厚公式
|
|
|
+ double numerator = p * d0;
|
|
|
+ double denominator = 2 * (sT * ej + p * y);
|
|
|
+ double tds = (numerator / denominator) + c2;
|
|
|
+ // 使用BigDecimal四舍五入到两位小数
|
|
|
+ return BigDecimal.valueOf(tds)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return thickness.getThicknessMin();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|