diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/postgre/SysUserColor.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/postgre/SysUserColor.java new file mode 100644 index 00000000..7a42ea99 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/postgre/SysUserColor.java @@ -0,0 +1,75 @@ +package org.jeecg.modules.base.entity.postgre; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +@Data +@TableName(value = "sys_user_color") +public class SysUserColor implements Serializable { + + /** + * id + */ + @TableId(value = "id", type = IdType.ASSIGN_ID) + private String id; + + /** + * 原谱曲线颜色 + */ + @TableField(value = "color_spec") + private String colorSpec; + + /** + * 拟合峰曲线颜色 + */ + @TableField(value = "color_peak") + private String colorPeak; + + /** + * LC曲线颜色 + */ + @TableField(value = "color_lc") + private String colorLc; + + /** + * BaseLine曲线颜色 + */ + @TableField(value = "color_base") + private String colorBase; + + /** + * Scac曲线颜色 + */ + @TableField(value = "color_scac") + private String colorScac; + + /** + * 比较谱曲线颜色 + */ + @TableField(value = "color_compare") + private String colorCompare; + + /** + * 拟合基线颜色 + */ + @TableField(value = "color_fitbase") + private String colorFitbase; + + /** + * 两谱和曲线颜色 + */ + @TableField(value = "color_strip") + private String colorStrip; + + /** + * 创建人 + */ + @TableField(value = "create_by") + private String createBy; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java index da536368..7254da77 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -1175,7 +1175,7 @@ public class GammaFileUtil { } } - public void UpdateChart(PHDFile phd, Map map){ + public void UpdateChart(PHDFile phd, Map map, Map colorMap){ List m_vCount = new LinkedList<>(); long m_nCount = phd.getSpec().getNum_g_channel(); long m_nSChan = phd.getSpec().getBegin_channel(); @@ -1191,11 +1191,11 @@ public class GammaFileUtil { if(m_nSChan == 0) { m_vCount.add(0L); } - ChartData shadowEnergyChart = this.Energy_Count(phd, m_vCount, m_nCount); - ChartData shadowChannelChart = this.Channel_Count(m_vCount, m_nCount); + ChartData shadowEnergyChart = this.Energy_Count(phd, m_vCount, m_nCount, colorMap.get("Color_Spec")); + ChartData shadowChannelChart = this.Channel_Count(m_vCount, m_nCount, colorMap.get("Color_Spec")); map.put("shadowEnergyChart", shadowEnergyChart); map.put("shadowChannelChart", shadowChannelChart); - List allData = AllData(false, phd, m_vCount, m_nCount); + List allData = AllData(false, phd, m_vCount, m_nCount, colorMap); map.put("allData", allData); List shapeEnergyData = Energy_BaseCP(phd); map.put("shapeEnergyData", shapeEnergyData); @@ -1203,7 +1203,7 @@ public class GammaFileUtil { map.put("shapeChannelData", shapeChannelData); } - public ChartData Energy_Count(PHDFile phd, List m_vCount, long m_nCount){ + public ChartData Energy_Count(PHDFile phd, List m_vCount, long m_nCount, String color){ int start = 0; long end = -1; //Energy @@ -1223,12 +1223,12 @@ public class GammaFileUtil { } data1.setName("Energy"); data1.setGroup("energy"); - data1.setColor("255,255,0"); + data1.setColor(color); } return data1; } - public ChartData Channel_Count(List m_vCount, long m_nCount){ + public ChartData Channel_Count(List m_vCount, long m_nCount, String color){ int start = 1; long end = -1; ChartData data1 = new ChartData(); @@ -1247,12 +1247,12 @@ public class GammaFileUtil { } data1.setName("Count"); data1.setGroup("channel"); - data1.setColor("255,255,0"); + data1.setColor(color); } return data1; } - public List Lc_Scac_base(boolean showLc, PHDFile phd, long m_nCount){ + public List Lc_Scac_base(boolean showLc, PHDFile phd, long m_nCount, Map colorMap){ List datalist = new LinkedList<>(); int start = 0; long end = -1; @@ -1306,26 +1306,26 @@ public class GammaFileUtil { // 颜色:原谱:0;峰:1;Lc:2;BaseLine:3;Scac:4;比较谱:5; data2.setGroup("channel"); data2.setName("Lc"); - data2.setColor("255,0,0"); + data2.setColor(colorMap.get("Color_Lc")); data2.setShow(showLc); data3.setGroup("channel"); data3.setName("Scac"); - data3.setColor("244,112,247"); + data3.setColor(colorMap.get("Color_Scac")); data3.setShow(showLc); data4.setGroup("channel"); data4.setName("BaseLine"); - data4.setColor("0,246,255"); + data4.setColor(colorMap.get("Color_Base")); data6.setGroup("energy"); data6.setName("Lc"); - data6.setColor("255,0,0"); + data6.setColor(colorMap.get("Color_Lc")); data6.setShow(showLc); data7.setGroup("energy"); data7.setName("Scac"); - data7.setColor("244,112,247"); + data7.setColor(colorMap.get("Color_Scac")); data7.setShow(showLc); data8.setGroup("energy"); data8.setName("BaseLine"); - data8.setColor("0,246,255"); + data8.setColor(colorMap.get("Color_Base")); data2.setType("Line"); data3.setType("Line"); data4.setType("Line"); @@ -1342,15 +1342,15 @@ public class GammaFileUtil { return datalist; } - public List Channel_Peak(PHDFile phd, long m_nCount){ - return PeakSet(phd.getVPeak(), phd.getVBase(), m_nCount, null, false); + public List Channel_Peak(PHDFile phd, long m_nCount, String color){ + return PeakSet(phd.getVPeak(), phd.getVBase(), color, m_nCount, null, false); } - public List Energy_Peak(PHDFile phd, long m_nCount){ - return PeakSet(phd.getVPeak(), phd.getVBase(), m_nCount, phd.getUsedEnerPara().getP(), true); + public List Energy_Peak(PHDFile phd, long m_nCount, String color){ + return PeakSet(phd.getVPeak(), phd.getVBase(), color, m_nCount, phd.getUsedEnerPara().getP(), true); } - public List PeakSet(List vPeak, List vBase, long m_nCount, List p, boolean bEnergy){ + public List PeakSet(List vPeak, List vBase, String color, long m_nCount, List p, boolean bEnergy){ System.loadLibrary("GammaAnaly"); List datalist = new LinkedList<>(); int peakNum = vPeak.size(); @@ -1386,7 +1386,7 @@ public class GammaFileUtil { PeakInfo peak = vPeak.get(i); ChartData cData = new ChartData(); - cData.setColor("255,127,39"); + cData.setColor(color); cData.setName("Peak"); List regChan = new LinkedList<>(); @@ -1464,13 +1464,13 @@ public class GammaFileUtil { return shapes; } - public List AllData(boolean showLc, PHDFile phd, List m_vCount, long m_nCount){ + public List AllData(boolean showLc, PHDFile phd, List m_vCount, long m_nCount, Map colorMap){ List datalist = new LinkedList<>(); - datalist.add(Channel_Count(m_vCount, m_nCount)); - datalist.add(Energy_Count(phd, m_vCount, m_nCount)); - datalist.addAll(Lc_Scac_base(showLc, phd, m_nCount)); - datalist.addAll(Channel_Peak(phd, m_nCount)); - datalist.addAll(Energy_Peak(phd, m_nCount)); + datalist.add(Channel_Count(m_vCount, m_nCount, colorMap.get("Color_Spec"))); + datalist.add(Energy_Count(phd, m_vCount, m_nCount, colorMap.get("Color_Spec"))); + datalist.addAll(Lc_Scac_base(showLc, phd, m_nCount, colorMap)); + datalist.addAll(Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak"))); + datalist.addAll(Energy_Peak(phd, m_nCount, colorMap.get("Color_Peak"))); return datalist; } @@ -1864,7 +1864,7 @@ public class GammaFileUtil { return mapLines; } - public ChartData Channel_BaseLine(PHDFile phd, long m_nCount) { + public ChartData Channel_BaseLine(PHDFile phd, long m_nCount, String color) { ChartData cData = new ChartData(); int start =0; long end = -1; @@ -1884,7 +1884,7 @@ public class GammaFileUtil { } cData.setGroup("channel"); cData.setName("BaseLine"); - cData.setColor("0,246,255"); + cData.setColor(color); cData.setType("Line"); } return cData; @@ -2038,7 +2038,7 @@ public class GammaFileUtil { if(CollectionUtils.isNotEmpty(m_curParam.getP())) { // 拟合曲线 ChartData lData = new ChartData(); - lData.setColor("255, 255, 0"); + lData.setColor("rgb(255, 255, 0)"); lData.setType("Line"); List vChan = new LinkedList<>(); @@ -2102,7 +2102,7 @@ public class GammaFileUtil { if(CollectionUtils.isNotEmpty(m_curParam.getP())) { // 拟合曲线 ChartData lData = new ChartData(); - lData.setColor("255, 255, 0"); + lData.setColor("rgb(255, 255, 0)"); lData.setType("Line"); List vChan = new LinkedList<>(); @@ -2235,7 +2235,7 @@ public class GammaFileUtil { if(CollectionUtils.isNotEmpty(m_curParam.getP())) { // 拟合曲线 ChartData lData = new ChartData(); - lData.setColor("255, 255, 0"); + lData.setColor("rgb(255, 255, 0)"); lData.setType("Line"); List vChan = new LinkedList<>(); @@ -3637,13 +3637,13 @@ public class GammaFileUtil { return nuclideList; } - public void InitTable(String name, Map map, PHDFile phd){ + public void InitTable(String name, Map map, PHDFile phd, Map colorMap){ InitNuclideInfo(name, map); long span = phd.getSpec().getG_energy_span(); List nuclideTableList = spectrumAnalysisMapper.getNuclideTable(name, span); if (CollectionUtils.isNotEmpty(nuclideTableList)){ map.put("table", nuclideTableList); - InitChart(nuclideTableList, phd, map); + InitChart(nuclideTableList, phd, map, colorMap); } } @@ -3679,13 +3679,13 @@ public class GammaFileUtil { } } - public void InitChart(List nuclideTableList, PHDFile phd, Map map){ + public void InitChart(List nuclideTableList, PHDFile phd, Map map, Map colorMap){ List> chartList = new LinkedList<>(); for (int i=0; i < nuclideTableList.size(); i++){ Map chartMap = new HashMap<>(); GardsNuclLinesLib item = nuclideTableList.get(i); double energy = item.getEnergy(); - List chartData = Energy_Count_Base(energy, 30, phd); + List chartData = Energy_Count_Base(energy, 30, phd, colorMap); String title = "Line" + (i+1); String bottom = "Abundance:" + item.getYield(); String selPos = energy+""; @@ -3700,7 +3700,7 @@ public class GammaFileUtil { map.put("chart", chartList); } - public List Energy_Count_Base(double energy, int chanNum, PHDFile phd) { + public List Energy_Count_Base(double energy, int chanNum, PHDFile phd, Map colorMap) { List datalist = new LinkedList<>(); int channel = GetChannelByEnergy(energy, 0, phd); int start = channel-chanNum/2, end = channel+chanNum/2; @@ -3711,12 +3711,12 @@ public class GammaFileUtil { end = (int) phd.getSpec().getNum_g_channel(); start = end - chanNum; } - datalist.add(Energy_CountCahrt(start, end, phd)); - datalist.add(Energy_BaseLine(start, end, phd)); + datalist.add(Energy_CountChart(start, end, phd, colorMap.get("Color_Spec"))); + datalist.add(Energy_BaseLine(start, end, phd, colorMap.get("Color_Base"))); return datalist; } - public ChartData Energy_CountCahrt(int start, int end, PHDFile phd) { + public ChartData Energy_CountChart(int start, int end, PHDFile phd, String color) { ChartData data1 = new ChartData(); if(phd.getSpec().getNum_g_channel() > 1 && phd.getVEnergy().size() == phd.getSpec().getNum_g_channel()) { if(start < 1){ @@ -3734,12 +3734,12 @@ public class GammaFileUtil { } data1.setName("Energy"); data1.setGroup("energy"); - data1.setColor("255,255,0"); // 颜色:原谱:0;峰:1;Lc:2;BaseLine:3;Scac:4;比较谱:5; + data1.setColor(color); // 颜色:原谱:0;峰:1;Lc:2;BaseLine:3;Scac:4;比较谱:5; } return data1; } - public ChartData Energy_BaseLine(int start, int end, PHDFile phd) { + public ChartData Energy_BaseLine(int start, int end, PHDFile phd, String color) { ChartData cData = new ChartData(); if(phd.getSpec().getNum_g_channel() > 1 && phd.getVEnergy().size() == phd.getSpec().getNum_g_channel() && phd.getVBase().size() == phd.getSpec().getNum_g_channel()) { if(start < 1){ @@ -3757,7 +3757,7 @@ public class GammaFileUtil { } cData.setGroup("energy"); cData.setName("BaseLine"); - cData.setColor("0,246,255"); + cData.setColor(color); cData.setType("Line"); } return cData; diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java index e2141efc..5cfdee78 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java @@ -49,8 +49,8 @@ public class GammaController { } @GetMapping("gammaByDB") - public Result gammaByDB(@RequestParam Integer sampleId, @RequestParam String dbName){ - return gammaService.gammaByDB(dbName, sampleId); + public Result gammaByDB(@RequestParam Integer sampleId, @RequestParam String dbName, HttpServletRequest request){ + return gammaService.gammaByDB(dbName, sampleId, request); } @GetMapping("gammaByFile") @@ -73,8 +73,8 @@ public class GammaController { @GetMapping("InteractiveTool") @ApiOperation(value = "analyze菜单下InteractiveTool页面数据", notes = "analyze菜单下InteractiveTool页面数据") - public Result InteractiveTool(@RequestParam Integer sampleId, @RequestParam String fileName) { - return gammaService.InteractiveTool(sampleId, fileName); + public Result InteractiveTool(@RequestParam Integer sampleId, @RequestParam String fileName, HttpServletRequest request) { + return gammaService.InteractiveTool(sampleId, fileName, request); } @GetMapping("insertPeak") @@ -85,20 +85,20 @@ public class GammaController { @PostMapping("acceptResults") @ApiOperation(value = "InteractiveTool页面Insert页面save", notes = "InteractiveTool页面Insert页面save") - public Result acceptResults(@RequestBody AcceptInfo acceptInfo) { - return gammaService.acceptResults(acceptInfo.getFileName(), acceptInfo.isAccept(), acceptInfo.getOldPeak()); + public Result acceptResults(@RequestBody AcceptInfo acceptInfo, HttpServletRequest request) { + return gammaService.acceptResults(acceptInfo.getFileName(), acceptInfo.isAccept(), acceptInfo.getOldPeak(), request); } @GetMapping("deletePeak") @ApiOperation(value = "InteractiveTool页面delete按钮", notes = "InteractiveTool页面delete按钮") - public Result deletePeak(String fileName, int curRow) { - return gammaService.deletePeak(fileName, curRow); + public Result deletePeak(String fileName, int curRow, HttpServletRequest request) { + return gammaService.deletePeak(fileName, curRow, request); } @GetMapping("getSelPosNuclide") @ApiOperation(value = "InteractiveTool页面选择channel加载对应核素信息接口", notes = "InteractiveTool页面选择channel加载对应核素信息接口") - public Result getSelPosNuclide(Integer sampleId, String fileName, int channel, String nuclides, HttpServletRequest request) { - return gammaService.getSelPosNuclide(sampleId, fileName, channel, nuclides, request); + public Result getSelPosNuclide(Integer sampleId, String fileName, int channel, HttpServletRequest request) { + return gammaService.getSelPosNuclide(sampleId, fileName, channel, request); } @PostMapping("addNuclide") @@ -145,8 +145,8 @@ public class GammaController { @GetMapping("changeNuclide") @ApiOperation(value = "Nuclide Review页面切换nuclide数据", notes = "Nuclide Review页面切换nuclide数据") - public Result changeNuclide(Integer sampleId, String fileName, String nuclideName) { - return gammaService.changeNuclide(sampleId, fileName, nuclideName); + public Result changeNuclide(Integer sampleId, String fileName, String nuclideName, HttpServletRequest request) { + return gammaService.changeNuclide(sampleId, fileName, nuclideName, request); } @GetMapping("searchNuclide") @@ -349,6 +349,24 @@ public class GammaController { return gammaService.viewGammaviewerLog(sampleId, fileName); } + @GetMapping("clickPeakInformation") + @ApiOperation(value = "gamma主页面点击peakInformation返回信息接口", notes = "gamma主页面点击peakInformation返回信息接口") + public Result clickPeakInformation(String fileName, int index) { + return gammaService.clickPeakInformation(fileName, index); + } + + @GetMapping("viewColorConfig") + @ApiOperation(value = "查看颜色配置信息", notes = "查看颜色配置信息") + public Result viewColorConfig(HttpServletRequest request) { + return gammaService.viewColorConfig(request); + } + + @PutMapping("updateColorConfig") + @ApiOperation(value = "修改颜色配置信息", notes = "修改颜色配置信息") + public Result updateColorConfig(@RequestBody ColorInfo colorInfo, HttpServletRequest request) { + return gammaService.updateColorConfig(colorInfo, request); + } + @GetMapping("saveToDB") @ApiOperation(value = "Save To DB按钮", notes = "Save To DB按钮") public Result saveToDB(String fileName, String userName) { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/ColorInfo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/ColorInfo.java new file mode 100644 index 00000000..f60183cf --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/ColorInfo.java @@ -0,0 +1,27 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class ColorInfo implements Serializable { + + private String colorSpec; + + private String colorPeak; + + private String colorLc; + + private String colorBase; + + private String colorScac; + + private String colorCompare; + + private String colorFitbase; + + private String colorStrip; + + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java index 04819932..a9306dde 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java @@ -146,6 +146,8 @@ public interface SpectrumAnalysisMapper { void deleteROIResults(Integer idAnalysis); + void insertROIResults(List roiResultsSpectrumList); + String getIdAnalysisByIdAnalyst(@Param(value = "sampleId") String sampleId, @Param(value = "userName") String userName); void deletePeaks(Integer idAnalysis); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysUserColorMapper.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysUserColorMapper.java new file mode 100644 index 00000000..3613c0d2 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysUserColorMapper.java @@ -0,0 +1,7 @@ +package org.jeecg.modules.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.jeecg.modules.base.entity.postgre.SysUserColor; + +public interface SysUserColorMapper extends BaseMapper { +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml index 7276fa95..458b6737 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml @@ -931,6 +931,42 @@ DELETE FROM RNMAN.GARDS_ROI_RESULTS WHERE IDANALYSIS=#{idAnalysis} + + + INSERT INTO + RNMAN.GARDS_ROI_RESULTS(SAMPLE_ID, + IDANALYSIS, + ROI, + LC, + S_GROSS, + G_GROSS, + B_GROSS, + S_NET, + G_NET, + NET, + NET_ERR, + CONC, + CONC_ERR, + MDC, + NID_FLAG) + VALUES(#{roiResultsSpectrum.sampleId}, + #{roiResultsSpectrum.idAnalysis}, + #{roiResultsSpectrum.roi}, + #{roiResultsSpectrum.lc}, + #{roiResultsSpectrum.sGross}, + #{roiResultsSpectrum.gGross}, + #{roiResultsSpectrum.bGross}, + #{roiResultsSpectrum.sNet}, + #{roiResultsSpectrum.gNet}, + #{roiResultsSpectrum.net}, + #{roiResultsSpectrum.netErr}, + #{roiResultsSpectrum.conc}, + #{roiResultsSpectrum.concErr}, + #{roiResultsSpectrum.mdc}, + #{roiResultsSpectrum.nidFlag}) + + + diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java index 2e9cf877..6f29787f 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java @@ -13,7 +13,7 @@ public interface IGammaService{ Result initValue(Integer sampleId, String dbName); - Result gammaByDB(String dbName, Integer sampleId); + Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request); Result gammaByFile(String fileName, HttpServletRequest request); @@ -21,15 +21,15 @@ public interface IGammaService{ Result Reprocessing(ConfigureData configureData, HttpServletRequest request); - Result InteractiveTool(Integer sampleId, String fileName); + Result InteractiveTool(Integer sampleId, String fileName, HttpServletRequest request); Result insertPeak(Integer sampleId, String fileName, Integer curChan); - Result acceptResults(String fileName, boolean accept, List oldPeak); + Result acceptResults(String fileName, boolean accept, List oldPeak, HttpServletRequest request); - Result deletePeak(String fileName, int curRow); + Result deletePeak(String fileName, int curRow, HttpServletRequest request); - Result getSelPosNuclide(Integer sampleId, String fileName, int channel, String nuclides, HttpServletRequest request); + Result getSelPosNuclide(Integer sampleId, String fileName, int channel, HttpServletRequest request); Result addNuclide(Integer curRow, String nuclideName, String fileName, List list_identify, HttpServletRequest request); @@ -45,7 +45,7 @@ public interface IGammaService{ Result nuclideReview(Integer sampleId, String fileName, Double channel, HttpServletRequest request); - Result changeNuclide(Integer sampleId, String fileName, String nuclideName); + Result changeNuclide(Integer sampleId, String fileName, String nuclideName, HttpServletRequest request); Result searchNuclide(Integer sampleId, String fileName, Double energy, Double tolerance, HttpServletRequest request); @@ -114,6 +114,12 @@ public interface IGammaService{ Result viewGammaviewerLog(Integer sampleId, String fileName); + Result clickPeakInformation(String fileName, int index); + + Result viewColorConfig(HttpServletRequest request); + + Result updateColorConfig(ColorInfo colorInfo, HttpServletRequest request); + Result saveToDB(String fileName, String userName); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysUserColorService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysUserColorService.java new file mode 100644 index 00000000..5c763476 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysUserColorService.java @@ -0,0 +1,15 @@ +package org.jeecg.modules.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.entity.postgre.SysUserColor; +import org.jeecg.modules.entity.vo.ColorInfo; + +import java.util.Map; + +public interface ISysUserColorService extends IService { + + Map initColor(String userName); + + Map updateColor(ColorInfo colorInfo, String userName); + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index a05ebb09..5b13b046 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -5,18 +5,16 @@ import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import org.apache.commons.lang3.StringUtils; import com.google.common.cache.Cache; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; -import org.jeecg.common.Excel.ExportExcel; import org.jeecg.common.api.vo.Result; import org.jeecg.common.cache.LocalCache; import org.jeecg.common.constant.DateConstant; @@ -32,11 +30,8 @@ import org.jeecg.modules.entity.*; import org.jeecg.modules.mapper.SpectrumAnalysisMapper; import org.jeecg.modules.native_jni.CalValuesHandler; import org.jeecg.modules.service.*; -import org.jeecgframework.poi.excel.ExcelExportUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.core.io.Resource; import org.springframework.stereotype.Service; import javax.servlet.ServletOutputStream; @@ -72,6 +67,8 @@ public class GammaServiceImpl implements IGammaService { @Autowired private ISysDefaultNuclideSpectrumService defaultNuclideSpectrumService; @Autowired + private ISysUserColorService sysUserColorService; + @Autowired private SpectrumAnalysisMapper spectrumAnalysisMapper; @Autowired private SpectrumPathProperties spectrumPathProperties; @@ -145,8 +142,9 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result gammaByDB(String dbName, Integer sampleId) { + public Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); Map map = new HashMap<>(); Cache phdCache = localCache.getPHDCache(); PHDFile phd = new PHDFile(); @@ -170,6 +168,8 @@ public class GammaServiceImpl implements IGammaService { if (!bRet){ return result; } + //获取当前角色配置的颜色信息 + Map colorMap = sysUserColorService.initColor(userName); // 更新 ‘QC Flags’ 状态 List qcstate = gammaFileUtil.Qcstate(phd); map.put("QCFlag", qcstate); @@ -182,7 +182,7 @@ public class GammaServiceImpl implements IGammaService { map.put("live_time", String.format("%.2f", phd.getAcq().getAcquisition_live_time())); double deadTime = (phd.getAcq().getAcquisition_real_time() - phd.getAcq().getAcquisition_live_time()) / phd.getAcq().getAcquisition_real_time(); map.put("dead_time", String.format("%.2f", deadTime*100)); - gammaFileUtil.UpdateChart(phd, map); + gammaFileUtil.UpdateChart(phd, map, colorMap); phdCache.put(fileName, phd); localCache.setPHDCache(phdCache); result.setSuccess(true); @@ -193,13 +193,16 @@ public class GammaServiceImpl implements IGammaService { @Override public Result gammaByFile(String fileName, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); Map map = new HashMap<>(); Cache phdCache = localCache.getPHDCache(); //上传文件路径 - String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + JwtUtil.getUserNameByToken(request); + String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; PHDFile phd = new PHDFile(); //加载文件内容 gammaFileUtil.loadFile(path, fileName, phd, result); + //获取当前角色的颜色配置 + Map colorMap = sysUserColorService.initColor(userName); // 更新 ‘QC Flags’ 状态 List qcstate = gammaFileUtil.Qcstate(phd); map.put("QCFlag", qcstate); @@ -212,7 +215,7 @@ public class GammaServiceImpl implements IGammaService { map.put("live_time", String.format("%.2f", phd.getAcq().getAcquisition_live_time())); double deadTime = (phd.getAcq().getAcquisition_real_time() - phd.getAcq().getAcquisition_live_time()) / phd.getAcq().getAcquisition_real_time(); map.put("dead_time", String.format("%.2f", deadTime*100)); - gammaFileUtil.UpdateChart(phd, map); + gammaFileUtil.UpdateChart(phd, map, colorMap); phdCache.put(fileName, phd); localCache.setPHDCache(phdCache); result.setSuccess(true); @@ -268,6 +271,8 @@ public class GammaServiceImpl implements IGammaService { return result; } String userName = JwtUtil.getUserNameByToken(request); + //获取当前角色的颜色配置 + Map colorMap = sysUserColorService.initColor(userName); //查询当前用户关联的核素信息 List nuclides = new LinkedList<>(); //从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 @@ -289,7 +294,7 @@ public class GammaServiceImpl implements IGammaService { phd.getUsedSetting().setRiskLevelK(configureData.getRiskLevelK()); phd.getUsedSetting().setRefTime_act(configureData.getRefTime_act()); phd.getUsedSetting().setRefTime_conc(configureData.getRefTime_conc()); - gammaFileUtil.UpdateChart(phd, map); + gammaFileUtil.UpdateChart(phd, map, colorMap); result.setSuccess(true); result.setResult(map); }else { @@ -302,8 +307,9 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result InteractiveTool(Integer sampleId, String fileName) { + public Result InteractiveTool(Integer sampleId, String fileName, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); Map map = new HashMap<>(); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); @@ -311,6 +317,7 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } + Map colorMap = sysUserColorService.initColor(userName); //表单 List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); map.put("table", vPeak); @@ -329,9 +336,9 @@ public class GammaServiceImpl implements IGammaService { if(m_nSChan == 0) { m_vCount.add(0L); } - ChartData channelCountChart = gammaFileUtil.Channel_Count(m_vCount, m_nCount); - ChartData channelBaseLineChart = gammaFileUtil.Channel_BaseLine(phd, m_nCount); - List channelPeakChart = gammaFileUtil.Channel_Peak(phd, m_nCount); + ChartData channelCountChart = gammaFileUtil.Channel_Count(m_vCount, m_nCount, colorMap.get("Color_Spec")); + ChartData channelBaseLineChart = gammaFileUtil.Channel_BaseLine(phd, m_nCount, colorMap.get("Color_Base")); + List channelPeakChart = gammaFileUtil.Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak")); List channelBaseCPChart = gammaFileUtil.Channel_BaseCP(phd); map.put("channelCountChart", channelCountChart); map.put("channelBaseLineChart", channelBaseLineChart); @@ -484,8 +491,9 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result acceptResults(String fileName, boolean accept, List oldPeak) { + public Result acceptResults(String fileName, boolean accept, List oldPeak, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); if (Objects.isNull(phd)){ @@ -495,7 +503,8 @@ public class GammaServiceImpl implements IGammaService { List m_vCount = new LinkedList<>(); long m_nCount = phd.getSpec().getNum_g_channel(); long m_nSChan = phd.getSpec().getBegin_channel(); - + //获取当前角色的颜色配置 + Map colorMap = sysUserColorService.initColor(userName); // 确保绘制曲线时所有谱都是从1道开始 int i = 0; if(m_nSChan == 0){ @@ -515,19 +524,19 @@ public class GammaServiceImpl implements IGammaService { List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); map.put("table", vPeak); - List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount); + List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak")); map.put("channelPeakChart", channelPeak); - ChartData channelBaseLine = gammaFileUtil.Channel_BaseLine(phd, m_nCount); + ChartData channelBaseLine = gammaFileUtil.Channel_BaseLine(phd, m_nCount, colorMap.get("Color_Base")); map.put("channelBaseLineChart", channelBaseLine); List differance = gammaFileUtil.Differance(phd, phd.getVPeak(), m_vCount, m_nCount); map.put("barChart", differance); - gammaFileUtil.UpdateChart(phd, map); + gammaFileUtil.UpdateChart(phd, map, colorMap); } else {//如果不保留 根据下标移除对应的vPeak数据 if (CollectionUtils.isNotEmpty(oldPeak)) { phd.getVPeak().clear(); phd.setVPeak(oldPeak); map.put("table", phd.getVPeak()); - List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount); + List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak")); map.put("channelPeakChart", channelPeak); } } @@ -537,14 +546,16 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result deletePeak(String fileName, int curRow) { + public Result deletePeak(String fileName, int curRow, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); if (Objects.isNull(phd)){ result.error500("请先选择解析文件!"); return result; } + Map colorMap = sysUserColorService.initColor(userName); long m_nCount = phd.getSpec().getNum_g_channel(); HashMap map = new HashMap<>(); int peakNum = phd.getVPeak().size(); @@ -562,9 +573,9 @@ public class GammaServiceImpl implements IGammaService { } List vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak()); map.put("table", vPeak); - List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount); + List channelPeak = gammaFileUtil.Channel_Peak(phd, m_nCount, colorMap.get("Color_Peak")); map.put("channelPeakChart", channelPeak); - gammaFileUtil.UpdateChart(phd, map); + gammaFileUtil.UpdateChart(phd, map, colorMap); } result.setSuccess(true); result.setResult(map); @@ -572,9 +583,9 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result getSelPosNuclide(Integer sampleId, String fileName, int channel, String nuclides, HttpServletRequest request) { + public Result getSelPosNuclide(Integer sampleId, String fileName, int channel, HttpServletRequest request) { Result result = new Result(); - Map> map = new HashMap<>(); + Map map = new HashMap<>(); String userName = JwtUtil.getUserNameByToken(request); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); @@ -597,11 +608,10 @@ public class GammaServiceImpl implements IGammaService { double min = phd.getVPeak().get(index).energy - phd.getSetting().getEnergyTolerance(); double max = phd.getVPeak().get(index).energy + phd.getSetting().getEnergyTolerance(); List list_possible = spectrumAnalysisMapper.getPossibleNuclide(userLib, min, max); + //用户当前已选中的核素名称 + List list_identify = phd.getVPeak().get(index).nuclides; - List list_identify = new LinkedList<>(); - List identify = Arrays.asList(nuclides.split(";")); - list_identify.addAll(identify); - + map.put("index", index); map.put("possible", list_possible); map.put("identify", list_identify); result.setSuccess(true); @@ -778,6 +788,7 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } + Map colorMap = sysUserColorService.initColor(userName); double value = gammaFileUtil.GetEnergyByFloatChan(phd, channel.intValue()); BigDecimal bigDecimal = BigDecimal.valueOf(value); bigDecimal = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP); @@ -793,7 +804,7 @@ public class GammaServiceImpl implements IGammaService { if(CollectionUtils.isNotEmpty(nuclideList)) { map.put("list", nuclideList); String name = nuclideList.get(0); - gammaFileUtil.InitTable(name, map, phd); + gammaFileUtil.InitTable(name, map, phd, colorMap); } else { map.put("list", nuclideList); map.put("chart", new LinkedList<>()); @@ -809,8 +820,9 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result changeNuclide(Integer sampleId, String fileName, String nuclideName) { + public Result changeNuclide(Integer sampleId, String fileName, String nuclideName, HttpServletRequest request) { Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); Map map = new HashMap<>(); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); @@ -818,7 +830,8 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } - gammaFileUtil.InitTable(nuclideName, map, phd); + Map colorMap = sysUserColorService.initColor(userName); + gammaFileUtil.InitTable(nuclideName, map, phd, colorMap); result.setSuccess(true); result.setResult(map); return result; @@ -835,6 +848,7 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } + Map colorMap = sysUserColorService.initColor(userName); BigDecimal bigDecimal = BigDecimal.valueOf(energy); bigDecimal = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP); map.put("energy", bigDecimal); @@ -849,7 +863,7 @@ public class GammaServiceImpl implements IGammaService { if(CollectionUtils.isNotEmpty(nuclideList)) { map.put("list", nuclideList); String name = nuclideList.get(0); - gammaFileUtil.InitTable(name, map, phd); + gammaFileUtil.InitTable(name, map, phd, colorMap); } else { map.put("list", nuclideList); map.put("chart", new LinkedList<>()); @@ -1615,15 +1629,7 @@ public class GammaServiceImpl implements IGammaService { tablePeak.setAreaErr(peak.area>0?String.format("%.3f",(peak.areaErr/peak.area)*100):"0"); tablePeak.setSignificant(String.format("%.3f", peak.significance)); tablePeak.setSensitivity(String.format("%.3f", peak.sensitivity)); - List nuclides = peak.nuclides; - String nuclide = ""; - if (CollectionUtils.isNotEmpty(nuclides)){ - for (String name:nuclides) { - nuclide+=name+StringPool.COMMA; - } - nuclide = nuclide.substring(0, nuclide.length()-1); - } - tablePeak.setIndentify(nuclide); + tablePeak.setIndentify(StringUtils.join(peak.nuclides, ";")); tablePeaks.add(tablePeak); } } @@ -2220,6 +2226,50 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result clickPeakInformation(String fileName, int index) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + int size = phd.getVPeak().size(); + //vPeak的数组大小大于0 当前下标在范围内 + if (size>0 && index=0) { + PeakInfo peak = phd.getVPeak().get(index); + String message = "Peak:"+String.format("%.2f", peak.peakCentroid)+" = "+String.format("%.2f", peak.energy)+" keV\n" + + "FWHM:"+String.format("%.2f", peak.fwhmc)+" keV\n" + + "Net Area:"+String.format("%.2f", peak.area)+"\n" + + "BaseLine:"+String.format("%.2f", phd.getVBase().get((int) Math.round(peak.peakCentroid)))+"\n" + + "NID:"+ StringUtils.join(peak.nuclides, ";"); + result.setSuccess(true); + result.setResult(message); + } + return result; + } + + @Override + public Result viewColorConfig(HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + Map colorMap = sysUserColorService.initColor(userName); + result.setSuccess(true); + result.setResult(colorMap); + return result; + } + + @Override + public Result updateColorConfig(ColorInfo colorInfo, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + Map colorMap = sysUserColorService.updateColor(colorInfo, userName); + result.setSuccess(true); + result.setResult(colorMap); + return result; + } + @Override public Result saveToDB(String fileName, String userName) { Result result = new Result(); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysUserColorServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysUserColorServiceImpl.java new file mode 100644 index 00000000..0a3da6d2 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysUserColorServiceImpl.java @@ -0,0 +1,85 @@ +package org.jeecg.modules.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.postgre.SysUserColor; +import org.jeecg.modules.entity.vo.ColorInfo; +import org.jeecg.modules.mapper.SysUserColorMapper; +import org.jeecg.modules.service.ISysUserColorService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@Service("sysUserColorService") +@DS("master") +public class SysUserColorServiceImpl extends ServiceImpl implements ISysUserColorService { + + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW) + public Map initColor(String userName) { + Map map = new HashMap<>(); + //查询数据库是否存在当前用户名的颜色数据 如果存在返回查询结果 如果不存在初始化当前用户的颜色信息 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysUserColor::getCreateBy, userName); + SysUserColor userColor = this.baseMapper.selectOne(queryWrapper); + if (Objects.isNull(userColor)) { + userColor = new SysUserColor(); + userColor.setId(String.valueOf(IdWorker.getId())); + userColor.setColorSpec("yellow"); + userColor.setColorPeak("rgb(255, 127, 39)"); + userColor.setColorLc("red"); + userColor.setColorBase("rgb(0, 246, 255)"); + userColor.setColorScac("rgb(244, 112, 247)"); + userColor.setColorCompare("green"); + userColor.setColorFitbase("white"); + userColor.setColorStrip("blue"); + userColor.setCreateBy(userName); + this.baseMapper.insert(userColor); + } + map.put("Color_Spec", userColor.getColorSpec()); + map.put("Color_Peak", userColor.getColorPeak()); + map.put("Color_Lc", userColor.getColorLc()); + map.put("Color_Base", userColor.getColorBase()); + map.put("Color_Scac", userColor.getColorScac()); + map.put("Color_Compare", userColor.getColorCompare()); + map.put("Color_Fitbase", userColor.getColorFitbase()); + map.put("Color_Strip", userColor.getColorStrip()); + return map; + } + + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW) + public Map updateColor(ColorInfo colorInfo, String userName) { + Map map = new HashMap<>(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysUserColor::getCreateBy, userName); + SysUserColor userColor = this.baseMapper.selectOne(queryWrapper); + if (Objects.nonNull(userColor)) { + userColor.setColorSpec(colorInfo.getColorSpec()); + userColor.setColorPeak(colorInfo.getColorPeak()); + userColor.setColorLc(colorInfo.getColorLc()); + userColor.setColorBase(colorInfo.getColorBase()); + userColor.setColorScac(colorInfo.getColorScac()); + userColor.setColorCompare(colorInfo.getColorCompare()); + userColor.setColorFitbase(colorInfo.getColorFitbase()); + userColor.setColorStrip(colorInfo.getColorStrip()); + this.baseMapper.updateById(userColor); + } + map.put("Color_Spec", userColor.getColorSpec()); + map.put("Color_Peak", userColor.getColorPeak()); + map.put("Color_Lc", userColor.getColorLc()); + map.put("Color_Base", userColor.getColorBase()); + map.put("Color_Scac", userColor.getColorScac()); + map.put("Color_Compare", userColor.getColorCompare()); + map.put("Color_Fitbase", userColor.getColorFitbase()); + map.put("Color_Strip", userColor.getColorStrip()); + return map; + } + +}