| | |
| | | import com.yuanchu.mom.pojo.Device; |
| | | import com.yuanchu.mom.service.DataConfigService; |
| | | import com.yuanchu.mom.service.DeviceService; |
| | | import com.yuanchu.mom.utils.DataAcquisition; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | |
| | | @ValueAuth |
| | | @ApiOperation(value = "判断该设备是否可以数采") |
| | | @GetMapping("/determineWhetherToCollectData") |
| | | public Result<?> determineWhetherToCollectData(@RequestParam("managementNumber") String managementNumber) { |
| | | public Result<?> determineWhetherToCollectData(@RequestParam("managementNumber") String managementNumber, HttpServletRequest request) { |
| | | String ip = DataAcquisition.getIp(request); |
| | | Device device = deviceService.getOne(Wrappers.<Device>lambdaQuery() |
| | | .eq(Device::getManagementNumber, managementNumber)); |
| | | .eq(Device::getManagementNumber, managementNumber) |
| | | .eq(Device::getIp, ip)); |
| | | if (ObjectUtils.isEmpty(device)) { |
| | | return Result.fail("设备编号错误!"); |
| | | return Result.success(false); |
| | | } |
| | | if (ObjectUtils.isEmpty(device.getFileType()) || ObjectUtils.isEmpty(device.getCollectUrl())) { |
| | | return Result.success(false); |
| | |
| | | private String y; |
| | | |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(value = "检验对象") |
| | | private String sample; |
| | | |
| | | @ApiModelProperty(value = "检验项目id") |
| | | private Integer structureItemParameterId; |
| | | } |
| | |
| | | public interface DataConfigMapper extends BaseMapper<DataConfig> { |
| | | |
| | | List<DeviceConfigDtoPage> selectDataConfigList(Integer deviceId); |
| | | |
| | | List<DataConfig> deleteDataConfig(); |
| | | } |
| | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty("检验项子项") |
| | | private String insProductItem; |
| | | |
| | | @ApiModelProperty("检验项id") |
| | | private Integer structureItemParameterId; |
| | | } |
| | |
| | | public interface DataConfigService extends IService<DataConfig> { |
| | | |
| | | List<DeviceConfigDtoPage> selectDataConfigList(Integer deviceId); |
| | | |
| | | List<DataConfig> deleteDataConfig(); |
| | | } |
| | |
| | | public List<DeviceConfigDtoPage> selectDataConfigList(Integer deviceId) { |
| | | return dataConfigMapper.selectDataConfigList(deviceId); |
| | | } |
| | | |
| | | @Override |
| | | public List<DataConfig> deleteDataConfig() { |
| | | return dataConfigMapper.deleteDataConfig(); |
| | | } |
| | | } |
| | |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | |
| | | return deviceMapper.deleteById(id); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int upDeviceParameter(Device itemParameter) { |
| | | // 删除数采集配置数据 |
| | | dataConfigService.deleteDataConfig(); |
| | | return deviceMapper.updateById(itemParameter); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public Result<?> dataAcquisition(HttpServletRequest request, Integer id, String entrustCode, String sampleCode) { |
| | | String ipAddress = request.getRemoteAddr(); |
| | | // 防止回环地址变为IPv6 |
| | | String ip = ipAddress.equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : ipAddress; |
| | | String ip = DataAcquisition.getIp(request); |
| | | List<Device> device = baseMapper.selectList(Wrappers.<Device>lambdaQuery() |
| | | .eq(Device::getIp, ip)); |
| | | if(device.size() > 1) { |
| | |
| | | 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; |
| | |
| | | return value; |
| | | } |
| | | } |
| | | |
| | | public static String getIp(HttpServletRequest request) { |
| | | String ipAddress = request.getRemoteAddr(); |
| | | // 防止回环地址变为IPv6 |
| | | return ipAddress.equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : ipAddress; |
| | | } |
| | | } |
| | |
| | | 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, |
| | | TRIM(BOTH '["]' FROM SUBSTRING_INDEX(REPLACE(ip.sample, '[["', ''), '"]]', 1)) sample, |
| | | ddc.formula, |
| | | ddc.referx, |
| | | ddc.refery, |
| | | ddc.x, |
| | | ddc.y, |
| | | ddc.id |
| | | ddc.id, |
| | | ip.id structureItemParameterId |
| | | FROM device d |
| | | left join structure_item_parameter ip on FIND_IN_SET(ip.id, d.ins_product_ids) |
| | | 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.inspection_item_subclass and |
| | | ip.inspection_item = ddc.inspection_item |
| | | left join device_data_config ddc on ddc.device_id = d.id and ddc.structure_item_parameter_id = ip.id |
| | | where d.id = #{deviceId} |
| | | </select> |
| | | |
| | | <select id="deleteDataConfig" resultType="com.yuanchu.mom.pojo.DataConfig"> |
| | | SELECT ddc.* |
| | | FROM device d |
| | | left join structure_item_parameter ip on not FIND_IN_SET(ip.id, d.ins_product_ids) |
| | | inner join device_data_config ddc on ddc.device_id = d.id and ddc.structure_item_parameter_id = ip.id |
| | | </select> |
| | | </mapper> |
| | |
| | | select d.device_name, d.management_number, d.file_type, d.collect_url |
| | | FROM |
| | | device d, |
| | | structure_item_parameter sip |
| | | device_data_config ddc |
| | | where d.ip = #{ip} |
| | | and sip.inspection_item = #{inspectionItem} |
| | | and ddc.inspection_item = #{inspectionItem} |
| | | <if test="inspectionItemSubclass != '' and inspectionItemSubclass != null"> |
| | | and sip.inspection_item_subclass = #{inspectionItemSubclass} |
| | | and ddc.inspection_item_subclass = #{inspectionItemSubclass} |
| | | </if> |
| | | and d.device_status = 0 |
| | | and d.ins_product_ids is not null |