| | |
| | | import com.yuanchu.mom.annotation.ValueClassify; |
| | | import com.yuanchu.mom.dto.DataConfigDto; |
| | | import com.yuanchu.mom.dto.DeviceDto; |
| | | import com.yuanchu.mom.exception.ErrorException; |
| | | import com.yuanchu.mom.pojo.DataConfig; |
| | | import com.yuanchu.mom.pojo.Device; |
| | | import com.yuanchu.mom.service.DataConfigService; |
| | |
| | | @PostMapping("/saveDataAcquisitionConfiguration") |
| | | public Result<?> saveDataAcquisitionConfiguration(@RequestParam(value = "deviceId") Integer deviceId, @RequestBody DataConfigDto dataConfigList) { |
| | | if (dataConfigList.getIsDevice()) { |
| | | System.out.println(); |
| | | Device one = deviceService.getOne(Wrappers.<Device>lambdaQuery() |
| | | .eq(Device::getIp, dataConfigList.getIp())); |
| | | if (ObjectUtils.isNotEmpty(one)) { |
| | | throw new ErrorException("该IP:" + dataConfigList.getIp() + "已经绑定了设备:" + one.getDeviceName()); |
| | | } |
| | | Device device = new Device(); |
| | | device.setId(deviceId); |
| | | device.setCollectUrl(dataConfigList.getCollectUrl()); |
| | |
| | | @GetMapping("/queryDataAcquisitionConfiguration") |
| | | public Result<?> queryDataAcquisitionConfiguration(@RequestParam("deviceId") Integer deviceId, |
| | | @RequestParam("isDevice") Boolean isDevice, |
| | | @RequestParam(value = "insProductItem", required = false) String insProductItem) { |
| | | @RequestParam(value = "inspectionItem", required = false) String inspectionItem, |
| | | @RequestParam(value = "inspectionItemSubclass", required = false) String inspectionItemSubclass) { |
| | | if (isDevice) { |
| | | List<DataConfig> list = dataConfigService.list(Wrappers.<DataConfig>lambdaQuery() |
| | | .eq(DataConfig::getDeviceId, deviceId) |
| | | .eq(DataConfig::getInsProductItem, insProductItem)); |
| | | .eq(DataConfig::getInspectionItem, inspectionItem) |
| | | .eq(DataConfig::getInspectionItemSubclass, inspectionItemSubclass)); |
| | | return Result.success(list); |
| | | } else { |
| | | return Result.success(dataConfigService.selectDataConfigList(deviceId)); |
| | |
| | | |
| | | @ValueTableShow(8) |
| | | @ApiModelProperty(value = "检验项子项") |
| | | private String inspectionItemSubClass; |
| | | private String inspectionItemSubclass; |
| | | |
| | | @ValueTableShow(9) |
| | | @ApiModelProperty(value = "公式") |
| | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 设备(Device)表数据库访问层 |
| | |
| | | |
| | | IPage<DeviceDto> selectDeviceParameterPage(Page page, @Param("ew") QueryWrapper<DeviceDto> queryWrappers); |
| | | |
| | | List<String> getInspectionItemSubclass(@Param("id") Integer id); |
| | | List<Map<String, Object>> getInspectionItemSubclass(@Param("id") Integer id); |
| | | } |
| | | |
| | |
| | | package com.yuanchu.mom.pojo; |
| | | |
| | | 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 io.swagger.annotations.ApiModel; |
| | |
| | | @ApiModelProperty("设备id") |
| | | private Integer deviceId; |
| | | |
| | | @ApiModelProperty("检验项目名称") |
| | | @ApiModelProperty("检验项目") |
| | | private String inspectionItem; |
| | | |
| | | @ApiModelProperty("检验项子项") |
| | | private String inspectionItemSubclass; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty("检验项子项") |
| | | private String insProductItem; |
| | | } |
| | |
| | | String ip = ipAddress.equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : ipAddress; |
| | | List<Device> device = baseMapper.selectList(Wrappers.<Device>lambdaQuery() |
| | | .eq(Device::getIp, ip)); |
| | | if(device.size() > 1) { |
| | | throw new ErrorException("IP:" + ip + "配置了设备多个设备,无法进行数采!"); |
| | | } |
| | | if (ObjectUtils.isEmpty(device)) { |
| | | throw new ErrorException("未给该IP:" + ip + "配置设备,无法进行数采!"); |
| | | } |
| | | List<String> inspectionItemSubclass = baseMapper.getInspectionItemSubclass(id); |
| | | Map<String, String> hashMap = new HashMap<>(); |
| | | device.forEach(i -> { |
| | | if (ObjectUtils.isEmpty(i.getFileType()) || ObjectUtils.isEmpty(i.getCollectUrl())) { |
| | | throw new ErrorException("未给该:" + i.getDeviceName() + "设备配置采集路径或文件后缀!"); |
| | | } |
| | | List<DataConfig> list = dataConfigService.list(Wrappers.<DataConfig>lambdaQuery() |
| | | .eq(DataConfig::getDeviceId, i.getId()) |
| | | .in(DataConfig::getInsProductItem, inspectionItemSubclass) |
| | | .orderBy(false, false, DataConfig::getId)); |
| | | hashMap.putAll(DataAcquisition.dataAcquisitionEntrance(request, list, i, entrustCode, sampleCode, ip)); |
| | | List<Map<String, Object>> inspectionItemSubclass = baseMapper.getInspectionItemSubclass(id); |
| | | if (ObjectUtils.isEmpty(device.get(0).getFileType()) || ObjectUtils.isEmpty(device.get(0).getCollectUrl())) { |
| | | throw new ErrorException("未给该:" + device.get(0).getDeviceName() + "设备配置采集路径或文件后缀!"); |
| | | } |
| | | List<DataConfig> list1 = new ArrayList<>(); |
| | | inspectionItemSubclass.forEach(i -> { |
| | | List<DataConfig> list = dataConfigService.list(Wrappers.<DataConfig>lambdaQuery() |
| | | .eq(DataConfig::getDeviceId, device.get(0).getId()) |
| | | .eq(DataConfig::getInspectionItem, i.get("inspection_item")) |
| | | .eq(DataConfig::getInspectionItemSubclass, i.get("inspection_item_subclass")) |
| | | .orderBy(false, false, DataConfig::getId)); |
| | | list1.addAll(list); |
| | | }); |
| | | String frequency = DataAcquisition.createFrequency(entrustCode, sampleCode); |
| | | hashMap.put("frequency", frequency); |
| | | return Result.success(hashMap); |
| | | Map<String, String> map = DataAcquisition.dataAcquisitionEntrance(list1, device.get(0), entrustCode, sampleCode, ip); |
| | | if (ObjectUtils.isNotEmpty(map)) { |
| | | String frequency = DataAcquisition.createFrequency(entrustCode, sampleCode); |
| | | map.put("frequency", frequency); |
| | | } |
| | | return Result.success(map); |
| | | } |
| | | } |
| | |
| | | import com.yuanchu.mom.pojo.DataConfig; |
| | | import com.yuanchu.mom.pojo.Device; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | |
| | | /** |
| | | * 数采入口 |
| | | * |
| | | * @param request |
| | | * @param dataConfig |
| | | * @param device |
| | | * @return |
| | | */ |
| | | public static Map<String, String> dataAcquisitionEntrance(HttpServletRequest request, List<DataConfig> dataConfig, Device device, String entrustCode, String sampleCode, String ip) { |
| | | public static Map<String, String> dataAcquisitionEntrance(List<DataConfig> dataConfig, Device device, String entrustCode, String sampleCode, String ip) { |
| | | String http = HTTP + ip + GETFILE + "?filePath=" + device.getCollectUrl() + "&fileExtension=" + device.getFileType(); |
| | | String result = null; |
| | | try { |
| | |
| | | } else { |
| | | String data = jsonObject.get("data").toString(); |
| | | // 考虑到一个检测项可能会存在多个数采配置,所以需要进行分组 |
| | | Map<String, List<DataConfig>> userMap = dataConfig.stream().collect(Collectors.groupingBy(DataConfig::getInsProductItem)); |
| | | Map<String, List<DataConfig>> userMap = dataConfig.stream() |
| | | .peek(i -> i.setInsProductItem( |
| | | i.getInspectionItem().equals(i.getInspectionItemSubclass()) ? i.getInspectionItem() + "," : i.getInspectionItem() + "," + i.getInspectionItemSubclass() |
| | | )) |
| | | .collect(Collectors.groupingBy(DataConfig::getInsProductItem)); |
| | | Map<String, String> map; |
| | | switch (device.getFileType()) { |
| | | case ".docx": |
| | |
| | | map = analysisMdb(data, userMap, entrustCode, sampleCode); |
| | | break; |
| | | case ".db": |
| | | map = analysisDb(data, userMap); |
| | | map = analysisDb(data, userMap, entrustCode, sampleCode); |
| | | break; |
| | | case ".png": |
| | | map = readPngString(data, userMap); |
| | |
| | | * @param dataConfig |
| | | * @return |
| | | */ |
| | | private static Map<String, String> analysisDb(String data, Map<String, List<DataConfig>> dataConfig) { |
| | | private static Map<String, String> analysisDb(String data, Map<String, List<DataConfig>> dataConfig, String entrustCode, String sampleCode) { |
| | | JSONObject jsonObject = JSON.parseObject(data); |
| | | JSONArray dataList = JSONArray.parseArray(jsonObject.get("data").toString()); |
| | | JSONArray columnList = JSONArray.parseArray(jsonObject.get("column").toString()); |
| | |
| | | List<Object> list = new ArrayList<>(); |
| | | for (int config = 0; config < v.size(); config++) { |
| | | String referx = getRefer(v.get(config).getReferx()); |
| | | int x = getXOrY(v.get(config).getX(), k, "X"); |
| | | int y = getXOrY(v.get(config).getY(), k, "Y"); |
| | | String key = ""; |
| | | for (int i = 0; i < columnList.size(); i++) { |
| | | if (columnList.get(i).equals(referx)) { |
| | | key = columnList.get(i + x).toString(); |
| | | for (int i = 0; i < dataList.size(); i++) { |
| | | JSONObject jsonObject1 = JSON.parseObject(dataList.get(i).toString()); |
| | | if (entrustCode.equals(jsonObject1.get("ExtInfo_Value1"))) { |
| | | Object o = jsonObject1.get(referx); |
| | | if (ObjectUtils.isNotEmpty(o)) { |
| | | list.add(o); |
| | | } |
| | | } |
| | | } |
| | | JSONObject jsonObject1 = JSON.parseObject(dataList.get(y).toString()); |
| | | Object o = jsonObject1.get(key); |
| | | if (ObjectUtils.isNotEmpty(o)) { |
| | | // 小数点进三位 |
| | | double v1 = 0; |
| | | try { |
| | | v1 = Double.parseDouble(o.toString()); |
| | | double v2 = v1 / 1000; |
| | | list.add(v2); |
| | | } catch (NumberFormatException e) { |
| | | list.add(o); |
| | | } |
| | | |
| | | } |
| | | } |
| | | // 进行公式计算 |
| | |
| | | List<Object> list = new ArrayList<>(); |
| | | for (int config = 0; config < v.size(); config++) { |
| | | String referx = getRefer(v.get(config).getReferx()); |
| | | int x = getXOrY(v.get(config).getX(), k, "X"); |
| | | String key = ""; |
| | | for (int i = 0; i < columnList.size(); i++) { |
| | | if (columnList.get(i).equals(referx)) { |
| | | key = columnList.get(i + x).toString(); |
| | | } |
| | | } |
| | | for (int i = 0; i < dataList.size(); i++) { |
| | | JSONObject jsonObject1 = JSON.parseObject(dataList.get(i).toString()); |
| | | if (entrustCode.equals(jsonObject1.get("OrderNumber")) && sampleCode.equals(jsonObject1.get("SampleNumber"))) { |
| | | Object o = jsonObject1.get(key); |
| | | Object o = jsonObject1.get(referx); |
| | | if (ObjectUtils.isNotEmpty(o)) { |
| | | list.add(o); |
| | | } |
| | |
| | | left join device_data_config ddc on ddc.device_id = d.id and |
| | | if(ip.inspection_item_subclass is not null and |
| | | ip.inspection_item_subclass != '', ip.inspection_item_subclass, |
| | | ip.inspection_item) = ddc.ins_product_item |
| | | ip.inspection_item) = ddc.inspection_item_subclass and |
| | | ip.inspection_item = ddc.inspection_item |
| | | where d.id = #{deviceId} |
| | | </select> |
| | | </mapper> |
| | |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.yuanchu.mom.mapper.DeviceMapper"> |
| | | |
| | | <select id="selectDeviceParameter" resultType="com.yuanchu.mom.pojo.Device"> |
| | | select * from( |
| | | select id, |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="getInspectionItemSubclass" resultType="java.lang.String"> |
| | | SELECT if(ip.inspection_item_subclass is not null and ip.inspection_item_subclass != '', |
| | | ip.inspection_item_subclass, ip.inspection_item) inspection_item_subclass FROM ins_product ip |
| | | <select id="getInspectionItemSubclass" resultType="map"> |
| | | SELECT ip.inspection_item, if(ip.inspection_item_subclass is not null and ip.inspection_item_subclass != '', |
| | | ip.inspection_item_subclass, ip.inspection_item) inspection_item_subclass |
| | | FROM ins_product ip |
| | | where ip.ins_sample_id = #{id} |
| | | </select> |
| | | </mapper> |
| | |
| | | |
| | | String seldepLimsId(int depLimsId); |
| | | |
| | | Map<String, Object> getDeviceMessage(@Param("ip")String ip, @Param("inspectionItem") String inspectionItem); |
| | | Map<String, Object> getDeviceMessage(@Param("ip")String ip, |
| | | @Param("inspectionItem") String inspectionItem, |
| | | @Param("inspectionItemSubclass") String inspectionItemSubclass); |
| | | } |
| | |
| | | // 防止回环地址变为IPv6 |
| | | String ip = ipAddress.equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : ipAddress; |
| | | insProducts.forEach(i -> { |
| | | Map<String, Object> devices = baseMapper.getDeviceMessage(ip, i.getInspectionItem()); |
| | | if (ObjectUtils.isNotEmpty(devices)) { |
| | | Map<String, Object> devices = baseMapper.getDeviceMessage(ip, i.getInspectionItem(), i.getInspectionItemSubclass()); |
| | | if (ObjectUtils.isNotEmpty(devices) && (ObjectUtils.isNotEmpty(devices.get("file_type")) || ObjectUtils.isNotEmpty(devices.get("collect_url")))) { |
| | | InsProductResult insProductResult = i.getInsProductResult(); |
| | | List<Object> list = new ArrayList<>(); |
| | | Map<Object, Object> hashMap = new HashMap<>(); |
| | |
| | | }); |
| | | return insProducts; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> checkSubmitPlan(Integer orderId, String laboratory) { |
| | | List<String> collect = new ArrayList<>(); |
| | |
| | | </select> |
| | | |
| | | <select id="getDeviceMessage" resultType="java.util.Map"> |
| | | select d.* |
| | | from device d, structure_item_parameter sip |
| | | select d.device_name, d.management_number |
| | | FROM |
| | | device d, |
| | | structure_item_parameter sip |
| | | where d.ip = #{ip} |
| | | and sip.inspection_item = #{inspectionItem} |
| | | limit 1 |
| | | <if test="inspectionItemSubclass != '' and inspectionItemSubclass != null"> |
| | | and sip.inspection_item_subclass = #{inspectionItemSubclass} |
| | | </if> |
| | | and d.device_status = 0 |
| | | and d.ins_product_ids is not null |
| | | </select> |
| | | </mapper> |