Commit 5a51c8b4 authored by 耿迪迪's avatar 耿迪迪

扫码结果解析及同步

parent 79d410d2
...@@ -84,6 +84,22 @@ ...@@ -84,6 +84,22 @@
<version>1.2.76</version> <version>1.2.76</version>
</dependency> </dependency>
<!-- redis 缓存操作 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.zehong.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;
import org.springframework.util.Assert;
import java.nio.charset.Charset;
/**
* Redis使用FastJson序列化
*
* @author zehong
*/
public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
{
@SuppressWarnings("unused")
private ObjectMapper objectMapper = new ObjectMapper();
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
private Class<T> clazz;
static
{
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
}
public FastJson2JsonRedisSerializer(Class<T> clazz)
{
super();
this.clazz = clazz;
}
@Override
public byte[] serialize(T t) throws SerializationException
{
if (t == null)
{
return new byte[0];
}
return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET);
}
@Override
public T deserialize(byte[] bytes) throws SerializationException
{
if (bytes == null || bytes.length <= 0)
{
return null;
}
String str = new String(bytes, DEFAULT_CHARSET);
return JSON.parseObject(str, clazz);
}
public void setObjectMapper(ObjectMapper objectMapper)
{
Assert.notNull(objectMapper, "'objectMapper' must not be null");
this.objectMapper = objectMapper;
}
protected JavaType getJavaType(Class<?> clazz)
{
return TypeFactory.defaultInstance().constructType(clazz);
}
}
package com.zehong.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* redis配置
*
* @author zehong
*/
@Configuration
@EnableCaching
public class RedisConfig extends CachingConfigurerSupport
{
@Bean
@SuppressWarnings(value = { "unchecked", "rawtypes" })
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory)
{
RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
serializer.setObjectMapper(mapper);
// 使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(serializer);
// Hash的key也采用StringRedisSerializer的序列化方式
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(serializer);
template.afterPropertiesSet();
return template;
}
}
package com.zehong.constant;
/**
* 设备数据接收项目常量类
* @author geng
* @since 2025-05-28
*/
public class MesDeviceDataConstant {
/**
* 设备对接 redis 前缀
*/
public static final String EQUIPMENT_DOCKING = "equipment_docking";
/**
* pcba device key
*/
public static final String PCBA_DEVICE_KEY = "pcba_device_key";
}
package com.zehong.constant;
/**
* pcba扫码规则
*/
public enum PCBACodeRules {
/**
* 卡批次码
*/
CARDBATCHCODE("(SL|SD|SY|QL|QD|QY)\\d{9}"),
/**
* 主板码
*/
MAINBOARDCODE("PCBA\\d{14}"),
/**
* 传感器批次码
*/
SENSORBATCHCODE("SEN\\d{9}");
private String regex;
PCBACodeRules(String regex) {
this.regex = regex;
}
public String getRegex() {
return regex;
}
}
package com.zehong.controller;
import com.zehong.entity.AjaxResult;
import com.zehong.service.ScanCodeResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 扫码结果
* @author geng
* @since 2025-05-27
*/
@RestController
@RequestMapping("/scan")
public class ScanCodeResultController extends BaseController{
@Autowired
private ScanCodeResultService scanCodeResultService;
@PostMapping("/scanCode")
public AjaxResult scanCode(@RequestBody String message) {
return toAjax(scanCodeResultService.scanCodeResult(message));
}
}
package com.zehong.dao; package com.zehong.dao;
import com.zehong.entity.PcbaDevices; import com.zehong.entity.PCBADevices;
import java.util.List; import java.util.List;
public interface AoiTestResultMapper { public interface PCBADevicesMapper {
/** /**
* 根据主板号查询设备信息 * 根据主板号查询设备信息
* @param motherboardCode 主板吗 * @param motherboardCode 主板吗
* @return * @return
*/ */
List<PcbaDevices> selectPcbaDeviceInfoByBoardCode(String motherboardCode); List<PCBADevices> selectPcbaDeviceInfoByBoardCode(String motherboardCode);
/** /**
* 更新设备信息 * 更新设备信息
* @param devices 设备信息 * @param devices 设备信息
* @return * @return
*/ */
int updatePcbaDeviceInfo(PcbaDevices devices); int updatePcbaDeviceInfo(PCBADevices devices);
/**
* 新增设备信息
* @param devices 设备信息
* @return
*/
int insertPcbaDevices(PCBADevices devices);
} }
package com.zehong.entity; package com.zehong.entity;
public class PcbaDevices { import java.util.Date;
public class PCBADevices {
/** id */ /** id */
private Long pcbaDevicesId; private Long pcbaDevicesId;
...@@ -17,6 +19,19 @@ public class PcbaDevices { ...@@ -17,6 +19,19 @@ public class PcbaDevices {
/**aoi检测结果*/ /**aoi检测结果*/
private String aoiDetectionResult; private String aoiDetectionResult;
/** 物联网卡批次号 */
private String iotCardBatchNumber;
/** 传感器码 */
private String sensorCode;
/** NB码 */
private String nbCode;
private Long materialInfoId;
private Date createTime;
public Long getPcbaDevicesId() { public Long getPcbaDevicesId() {
return pcbaDevicesId; return pcbaDevicesId;
} }
...@@ -56,4 +71,44 @@ public class PcbaDevices { ...@@ -56,4 +71,44 @@ public class PcbaDevices {
public void setAoiDetectionResult(String aoiDetectionResult) { public void setAoiDetectionResult(String aoiDetectionResult) {
this.aoiDetectionResult = aoiDetectionResult; this.aoiDetectionResult = aoiDetectionResult;
} }
public String getIotCardBatchNumber() {
return iotCardBatchNumber;
}
public void setIotCardBatchNumber(String iotCardBatchNumber) {
this.iotCardBatchNumber = iotCardBatchNumber;
}
public String getSensorCode() {
return sensorCode;
}
public void setSensorCode(String sensorCode) {
this.sensorCode = sensorCode;
}
public String getNbCode() {
return nbCode;
}
public void setNbCode(String nbCode) {
this.nbCode = nbCode;
}
public Long getMaterialInfoId() {
return materialInfoId;
}
public void setMaterialInfoId(Long materialInfoId) {
this.materialInfoId = materialInfoId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
} }
package com.zehong.service;
/**
* 扫码结果
*/
public interface ScanCodeResultService {
/**
* 扫码结果
* @param message 扫码信息
* @return
*/
int scanCodeResult(String message);
}
...@@ -4,14 +4,13 @@ import com.alibaba.fastjson.JSON; ...@@ -4,14 +4,13 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.zehong.dao.AoiTestResultMapper; import com.zehong.dao.PCBADevicesMapper;
import com.zehong.entity.PcbaDevices; import com.zehong.entity.PCBADevices;
import com.zehong.service.AoiTestResultService; import com.zehong.service.AoiTestResultService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
...@@ -27,7 +26,7 @@ public class AoiTestResultServiceImpl implements AoiTestResultService{ ...@@ -27,7 +26,7 @@ public class AoiTestResultServiceImpl implements AoiTestResultService{
private static final Logger log = LoggerFactory.getLogger(AoiTestResultServiceImpl.class); private static final Logger log = LoggerFactory.getLogger(AoiTestResultServiceImpl.class);
@Resource @Resource
private AoiTestResultMapper aoiTestResultMapper; private PCBADevicesMapper pcbaDevicesMapper;
/** /**
* AOI检查结果同步 * AOI检查结果同步
...@@ -42,12 +41,12 @@ public class AoiTestResultServiceImpl implements AoiTestResultService{ ...@@ -42,12 +41,12 @@ public class AoiTestResultServiceImpl implements AoiTestResultService{
for(Object obj : boardData){ for(Object obj : boardData){
JSONObject boardInfo = (JSONObject)obj; JSONObject boardInfo = (JSONObject)obj;
String motherboardCode = boardInfo.getString("board_sn"); String motherboardCode = boardInfo.getString("board_sn");
List<PcbaDevices> devices = aoiTestResultMapper.selectPcbaDeviceInfoByBoardCode(motherboardCode); List<PCBADevices> devices = pcbaDevicesMapper.selectPcbaDeviceInfoByBoardCode(motherboardCode);
if(!CollectionUtils.isEmpty(devices)){ if(!CollectionUtils.isEmpty(devices)){
for(PcbaDevices device : devices){ for(PCBADevices device : devices){
String finalResult = boardInfo.getString("board_final_result"); String finalResult = boardInfo.getString("board_final_result");
device.setAoiDetectionResult(finalResult); device.setAoiDetectionResult(finalResult);
insertResult += aoiTestResultMapper.updatePcbaDeviceInfo(device); insertResult += pcbaDevicesMapper.updatePcbaDeviceInfo(device);
} }
} }
} }
......
package com.zehong.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.zehong.constant.MesDeviceDataConstant;
import com.zehong.constant.PCBACodeRules;
import com.zehong.dao.PCBADevicesMapper;
import com.zehong.entity.PCBADevices;
import com.zehong.service.ScanCodeResultService;
import com.zehong.utils.RedisCache;
import com.zehong.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 扫码结果
*/
@Service
@DS("mes")
public class ScanCodeResultServiceImpl implements ScanCodeResultService{
private static final Logger log = LoggerFactory.getLogger(ScanCodeResultServiceImpl.class);
@Autowired
private RedisCache redisCache;
@Resource
private PCBADevicesMapper pcbaDevicesMapper;
/**
* 扫码规则
*/
private final Map<String,Pattern> rules = new HashMap<>();
{
for(PCBACodeRules rule: PCBACodeRules.values()){
rules.put(rule.name(),Pattern.compile(rule.getRegex()));
}
}
/**
* 扫码结果
* @param message 扫码信息
* @return
*/
@Override
public int scanCodeResult(String message) {
log.info("扫码结果字符串=========" + message);
//解析字符串
Map<String,Object> analysisResult = analysis(message);
//数据处理
return dealStrategy(analysisResult);
}
/**
* 解析扫码结果
* @param message
*/
private Map<String,Object> analysis(String message){
Map<String,Object> analysisResult = new HashMap<>();
for(Map.Entry<String, Pattern> rule : rules.entrySet()){
List<String> codes = new ArrayList<>();
Matcher m = rule.getValue().matcher(message);
while (m.find()){
String code = m.group();
codes.add(code);
message = message.replace(code,"");
}
if(!CollectionUtils.isEmpty(codes)) analysisResult.put(rule.getKey(),codes);
}
//nb码无规则
if(StringUtils.isNotEmpty(message)) analysisResult.put("nbCode",message);
return analysisResult;
}
/**
* 处理策略
* @param analysisResult
*/
private int dealStrategy(Map<String,Object> analysisResult){
// NB码 + 卡批次码
if(analysisResult.containsKey("nbCode") && analysisResult.containsKey(PCBACodeRules.CARDBATCHCODE.name())){
return addNbAndCardCode(analysisResult);
}
// 主板码 + 传感器批次码
if(analysisResult.containsKey(PCBACodeRules.MAINBOARDCODE.name()) && analysisResult.containsKey(PCBACodeRules.SENSORBATCHCODE.name())){
return addMainBoardCodeAndSensorBatchCode(analysisResult);
}
//主板码 + NB码
if(analysisResult.containsKey(PCBACodeRules.MAINBOARDCODE.name()) && analysisResult.containsKey("nbCode")){
return updateMainBoardCodeAndNb(analysisResult);
}
return 0;
}
/**
* 新增nb+卡批次码
* @param analysisResult
* @return
*/
public int addNbAndCardCode(Map<String,Object> analysisResult){
Map<String,Object> cache = redisCache.getCacheMap(MesDeviceDataConstant.EQUIPMENT_DOCKING + ":" + MesDeviceDataConstant.PCBA_DEVICE_KEY);
if(null != cache){
PCBADevices devices = new PCBADevices();
devices.setMotherboardCode(analysisResult.get("nbCode").toString());
List<String> codes = (List<String>) analysisResult.get(PCBACodeRules.CARDBATCHCODE.name());
devices.setIotCardBatchNumber(codes.get(0));
devices.setPcbaProductionTasksNumber(cache.get("pcbaProductionTasksNumber").toString());
devices.setMaterialInfoId((Long)cache.get("materialInfoId"));
devices.setCreateTime(new Date());
return pcbaDevicesMapper.insertPcbaDevices(devices);
}
return 0;
}
/**
* 新增主板码+传感器批次码
* @param analysisResult
* @return
*/
public int addMainBoardCodeAndSensorBatchCode(Map<String,Object> analysisResult){
Map<String,Object> cache = redisCache.getCacheMap(MesDeviceDataConstant.EQUIPMENT_DOCKING + ":" + MesDeviceDataConstant.PCBA_DEVICE_KEY);
if(null != cache){
PCBADevices devices = new PCBADevices();
List<String> mainCodes = (List<String>) analysisResult.get(PCBACodeRules.MAINBOARDCODE.name());
devices.setMotherboardCode(mainCodes.get(0));
List<String> sensorCodes = (List<String>) analysisResult.get(PCBACodeRules.SENSORBATCHCODE.name());
devices.setSensorCode(sensorCodes.get(0));
devices.setPcbaProductionTasksNumber(cache.get("pcbaProductionTasksNumber").toString());
devices.setMaterialInfoId((Long)cache.get("materialInfoId"));
devices.setCreateTime(new Date());
return pcbaDevicesMapper.insertPcbaDevices(devices);
}
return 0;
}
/**
* 修改主板码和nb码
* @param analysisResult
* @return
*/
public int updateMainBoardCodeAndNb(Map<String,Object> analysisResult){
Map<String,Object> cache = redisCache.getCacheMap(MesDeviceDataConstant.EQUIPMENT_DOCKING + ":" + MesDeviceDataConstant.PCBA_DEVICE_KEY);
if(null != cache){
PCBADevices devices = new PCBADevices();
List<String> mainCodes = (List<String>) analysisResult.get(PCBACodeRules.MAINBOARDCODE.name());
devices.setMotherboardCode(mainCodes.get(0));
devices.setNbCode(analysisResult.get("nbCode").toString());
devices.setPcbaBatchNumber(cache.get("pcbaProductionTasksNumber").toString());
devices.setMaterialInfoId((Long)cache.get("materialInfoId"));
devices.setCreateTime(new Date());
return pcbaDevicesMapper.insertPcbaDevices(devices);
}
return 0;
}
}
package com.zehong.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundSetOperations;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* spring redis 工具类
*
* @author zehong
**/
@SuppressWarnings(value = { "unchecked", "rawtypes" })
@Component
public class RedisCache
{
@Autowired
public RedisTemplate redisTemplate;
/**
* 缓存基本的对象,Integer、String、实体类等
*
* @param key 缓存的键值
* @param value 缓存的值
*/
public <T> void setCacheObject(final String key, final T value)
{
redisTemplate.opsForValue().set(key, value);
}
/**
* 缓存基本的对象,Integer、String、实体类等
*
* @param key 缓存的键值
* @param value 缓存的值
* @param timeout 时间
* @param timeUnit 时间颗粒度
*/
public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
{
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
}
/**
* 设置有效时间
*
* @param key Redis键
* @param timeout 超时时间
* @return true=设置成功;false=设置失败
*/
public boolean expire(final String key, final long timeout)
{
return expire(key, timeout, TimeUnit.SECONDS);
}
/**
* 设置有效时间
*
* @param key Redis键
* @param timeout 超时时间
* @param unit 时间单位
* @return true=设置成功;false=设置失败
*/
public boolean expire(final String key, final long timeout, final TimeUnit unit)
{
return redisTemplate.expire(key, timeout, unit);
}
/**
* 获得缓存的基本对象。
*
* @param key 缓存键值
* @return 缓存键值对应的数据
*/
public <T> T getCacheObject(final String key)
{
ValueOperations<String, T> operation = redisTemplate.opsForValue();
return operation.get(key);
}
/**
* 删除单个对象
*
* @param key
*/
public boolean deleteObject(final String key)
{
return redisTemplate.delete(key);
}
/**
* 删除集合对象
*
* @param collection 多个对象
* @return
*/
public long deleteObject(final Collection collection)
{
return redisTemplate.delete(collection);
}
/**
* 缓存List数据
*
* @param key 缓存的键值
* @param dataList 待缓存的List数据
* @return 缓存的对象
*/
public <T> long setCacheList(final String key, final List<T> dataList)
{
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
return count == null ? 0 : count;
}
/**
* 获得缓存的list对象
*
* @param key 缓存的键值
* @return 缓存键值对应的数据
*/
public <T> List<T> getCacheList(final String key)
{
return redisTemplate.opsForList().range(key, 0, -1);
}
/**
* 缓存Set
*
* @param key 缓存键值
* @param dataSet 缓存的数据
* @return 缓存数据的对象
*/
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
{
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
Iterator<T> it = dataSet.iterator();
while (it.hasNext())
{
setOperation.add(it.next());
}
return setOperation;
}
/**
* 获得缓存的set
*
* @param key
* @return
*/
public <T> Set<T> getCacheSet(final String key)
{
return redisTemplate.opsForSet().members(key);
}
/**
* 缓存Map
*
* @param key
* @param dataMap
*/
public <T> void setCacheMap(final String key, final Map<String, T> dataMap)
{
if (dataMap != null) {
redisTemplate.opsForHash().putAll(key, dataMap);
}
}
/**
* 获得缓存的Map
*
* @param key
* @return
*/
public <T> Map<String, T> getCacheMap(final String key)
{
return redisTemplate.opsForHash().entries(key);
}
/**
* 往Hash中存入数据
*
* @param key Redis键
* @param hKey Hash键
* @param value 值
*/
public <T> void setCacheMapValue(final String key, final String hKey, final T value)
{
redisTemplate.opsForHash().put(key, hKey, value);
}
/**
* 获取Hash中的数据
*
* @param key Redis键
* @param hKey Hash键
* @return Hash中的对象
*/
public <T> T getCacheMapValue(final String key, final String hKey)
{
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
return opsForHash.get(key, hKey);
}
/**
* 获取多个Hash中的数据
*
* @param key Redis键
* @param hKeys Hash键集合
* @return Hash对象集合
*/
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys)
{
return redisTemplate.opsForHash().multiGet(key, hKeys);
}
/**
* 获得缓存的基本对象列表
*
* @param pattern 字符串前缀
* @return 对象列表
*/
public Collection<String> keys(final String pattern)
{
return redisTemplate.keys(pattern);
}
}
This diff is collapsed.
...@@ -5,3 +5,24 @@ spring: ...@@ -5,3 +5,24 @@ spring:
password: zehong_/sjz!D password: zehong_/sjz!D
url: jdbc:mysql://36.148.1.253:3309/gas_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://36.148.1.253:3309/gas_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
# redis 配置
redis:
host: 36.138.180.82
port: 63798
# 数据库索引
database: 0
# 密码
password: 1qaz2wsx3edc@
# 连接超时时间
timeout: 10s
jedis:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
\ No newline at end of file
...@@ -15,3 +15,24 @@ spring: ...@@ -15,3 +15,24 @@ spring:
url: jdbc:mysql://36.138.180.82:3309/zh_mes_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true url: jdbc:mysql://36.138.180.82:3309/zh_mes_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true
username: zh_mes_db username: zh_mes_db
password: Dba5CdmBm3tdJ4ph password: Dba5CdmBm3tdJ4ph
# redis 配置
redis:
host: 36.138.180.82
port: 63798
# 数据库索引
database: 0
# 密码
password: 1qaz2wsx3edc@
# 连接超时时间
timeout: 10s
jedis:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.dao.AoiTestResultMapper"> <mapper namespace="com.zehong.dao.PCBADevicesMapper">
<resultMap type="PcbaDevices" id="PcbaDevicesResult"> <resultMap type="PCBADevices" id="PcbaDevicesResult">
<result property="pcbaDevicesId" column="f_pcba_devices_id" /> <result property="pcbaDevicesId" column="f_pcba_devices_id" />
<result property="motherboardCode" column="f_motherboard_code" /> <result property="motherboardCode" column="f_motherboard_code" />
<result property="pcbaProductionTasksNumber" column="f_pcba_production_tasks_number" /> <result property="pcbaProductionTasksNumber" column="f_pcba_production_tasks_number" />
<result property="pcbaBatchNumber" column="f_pcba_batch_number" /> <result property="pcbaBatchNumber" column="f_pcba_batch_number" />
<result property="aoiDetectionResult" column="f_aoi_detection_result" /> <result property="aoiDetectionResult" column="f_aoi_detection_result" />
<result property="iotCardBatchNumber" column="iot_card_batch_number" />
<result property="sensorCode" column="f_sensor_code" />
<result property="nbCode" column="f_nb_code" />
<result property="materialInfoId" column="f_material_info_id" />
</resultMap> </resultMap>
...@@ -30,8 +34,38 @@ ...@@ -30,8 +34,38 @@
<if test="pcbaProductionTasksNumber != null">f_pcba_production_tasks_number = #{pcbaProductionTasksNumber},</if> <if test="pcbaProductionTasksNumber != null">f_pcba_production_tasks_number = #{pcbaProductionTasksNumber},</if>
<if test="pcbaBatchNumber != null">f_pcba_batch_number = #{pcbaBatchNumber},</if> <if test="pcbaBatchNumber != null">f_pcba_batch_number = #{pcbaBatchNumber},</if>
<if test="aoiDetectionResult != null">f_aoi_detection_result = #{aoiDetectionResult},</if> <if test="aoiDetectionResult != null">f_aoi_detection_result = #{aoiDetectionResult},</if>
<if test="sensorCode != null">f_sensor_code = #{sensorCode},</if>
<if test="nbCode != null">f_nb_code = #{nbCode},</if>
<if test="iotCardBatchNumber != null">iot_card_batch_number = #{iotCardBatchNumber},</if>
<if test="materialInfoId != null">f_material_info_id,</if>
</trim> </trim>
where f_pcba_devices_id = #{pcbaDevicesId} where f_pcba_devices_id = #{pcbaDevicesId}
</update> </update>
<insert id="insertPcbaDevices" parameterType="PcbaDevices" useGeneratedKeys="true" keyProperty="pcbaDevicesId">
insert into t_pcba_devices
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="motherboardCode != null">f_motherboard_code,</if>
<if test="pcbaProductionTasksNumber != null">f_pcba_production_tasks_number,</if>
<if test="pcbaBatchNumber != null">f_pcba_batch_number,</if>
<if test="materialInfoId != null">f_material_info_id,</if>
<if test="sensorCode != null">f_sensor_code,</if>
<if test="nbCode != null">f_nb_code,</if>
<if test="createTime != null">f_create_time,</if>
<if test="iotCardBatchNumber != null">iot_card_batch_number,</if>
<if test="aoiDetectionResult != null">f_aoi_detection_result,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="motherboardCode != null">#{motherboardCode},</if>
<if test="pcbaProductionTasksNumber != null">#{pcbaProductionTasksNumber},</if>
<if test="pcbaBatchNumber != null">#{pcbaBatchNumber},</if>
<if test="materialInfoId != null">#{materialInfoId},</if>
<if test="sensorCode != null">#{sensorCode},</if>
<if test="nbCode != null">#{nbCode},</if>
<if test="createTime != null">#{createTime},</if>
<if test="iotCardBatchNumber != null">#{iotCardBatchNumber},</if>
<if test="aoiDetectionResult != null">#{aoiDetectionResult},</if>
</trim>
</insert>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment