chen %!s(int64=2) %!d(string=hai) anos
pai
achega
e95c616d4b

+ 8 - 3
src/main/java/org/springblade/api/CameraApiController.java

@@ -105,17 +105,18 @@ public class CameraApiController {
 					productImageRecord.setMessage("未找到相机Mac地址为'"+macAddress+"'的设备信息");
 				}else{
 					productImageRecord.setEquipmentId(equipmentEntity.getId());
+					productImageRecord.setEqSn(equipmentEntity.getEqSn());
 					if(productCode.length()<25){
 						productImageRecord.setStatus(2);
 						productImageRecord.setMessage("产品码'"+productCode+"'小于18位");
 					}else{
 						String code = productCode.substring(8,12);
-						ProductModelEntity productModel = productModelService.getOne(Wrappers.<ProductModelEntity>lambdaQuery().eq(ProductModelEntity::getProductSpec,code),false);
+						ProductModelEntity productModel = productModelService.getOne(Wrappers.<ProductModelEntity>lambdaQuery().eq(ProductModelEntity::getProductSpec,code).eq(ProductModelEntity::getFactoryId,equipmentEntity.getFactoryId()),false);
 						if(productModel==null){
 							productImageRecord.setStatus(2);
 							productImageRecord.setMessage("未找到型号码为'"+code+"'的数据");
 						}else{
-							ProductEntity productEntity = productService.getOne(Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getQrCode,productCode).eq(ProductEntity::getTenantId,equipmentEntity.getTenantId()),false);
+							ProductEntity productEntity = productService.getOne(Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getQrCode,productCode).eq(ProductEntity::getFactoryId,equipmentEntity.getFactoryId()),false);
 							if(productEntity==null){
 								productEntity = new ProductEntity();
 								productEntity.setTenantId(productModel.getTenantId());
@@ -128,6 +129,8 @@ public class CameraApiController {
 								productEntity.setQrCode(productCode);
 								productEntity.setStatus(2);
 								productService.save(productEntity);
+								productImageRecord.setMessage("成功");
+								productImageRecord.setProductId(productEntity.getId());
 							}else{
 								if(productEntity.getStatus()==2){
 									productEntity.setFrontImg(bladeFile.getLink());
@@ -143,6 +146,9 @@ public class CameraApiController {
 					}
 				}
 				productImageRecordService.save(productImageRecord);
+				if(equipmentEntity!=null){
+					webSocketServer.sendToOne(equipmentEntity.getEqSn(), JSONObject.toJSONString(productImageRecord));
+				}
 
 				if(productImageRecord.getStatus()==2){
 					return R.fail(productImageRecord.getMessage());
@@ -155,7 +161,6 @@ public class CameraApiController {
 		result.put("macAddress",macAddress);
 		result.put("productCode",productCode);
 		result.put("imgUrl",fileUrl);
-//		webSocketServer.sendToOne(macAddress, JSONObject.toJSONString(result));
 		return R.data(result);
 
 	}

+ 53 - 0
src/main/java/org/springblade/app/AppApiController.java

@@ -0,0 +1,53 @@
+package org.springblade.app;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.modules.pl.product.entity.ProductEntity;
+import org.springblade.modules.pl.product.entity.ProductImageRecordEntity;
+import org.springblade.modules.pl.product.service.IProductImageRecordService;
+import org.springblade.modules.pl.product.vo.ProductImageRecordVO;
+import org.springblade.modules.pl.product.vo.ProductVO;
+import org.springblade.modules.pl.product.wrapper.ProductImageRecordWrapper;
+import org.springblade.modules.pl.product.wrapper.ProductWrapper;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.util.Map;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("app/api")
+@Api(value = "app接口", tags = "app相关外放接口")
+@Slf4j
+public class AppApiController {
+	private final IProductImageRecordService productImageRecordService;
+
+	/**
+	 * 产品拍照 分页
+	 */
+	@GetMapping("/productImgList")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "产品拍照", notes = "传入product")
+	public R<?> productImgList(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
+		if(param.get("eqSn")==null){
+			return R.fail("设备序列号不能为空");
+		}
+		query.setDescs("create_time");
+		QueryWrapper<ProductImageRecordEntity> wrapper = Condition.getQueryWrapper(param,ProductImageRecordEntity.class);
+		IPage<ProductImageRecordEntity> pages = productImageRecordService.page(Condition.getPage(query),wrapper);
+		return R.data(ProductImageRecordWrapper.build().pageVO(pages));
+	}
+}

+ 1 - 0
src/main/java/org/springblade/applet/ProductReworkApiController.java

@@ -50,6 +50,7 @@ public class ProductReworkApiController {
 	@ApiOperationSupport(order = 3)
 	@ApiOperation(value = "分页", notes = "传入productRework")
 	public R<IPage<ProductReworkEntity>> page(ProductReworkVO productRework, Query query) {
+		query.setDescs("create_time");
 		BladeUser user = AuthUtil.getUser();
 		productRework.setFactoryId(user.getFactoryId());
 		QueryWrapper<ProductReworkEntity> queryWrapper = Condition.getQueryWrapper(productRework);

+ 5 - 0
src/main/java/org/springblade/modules/pl/product/entity/ProductImageRecordEntity.java

@@ -51,6 +51,11 @@ public class ProductImageRecordEntity extends TenantEntity {
 	 */
 	@ApiModelProperty(value = "设备id")
 	private Long equipmentId;
+	/**
+	 * 设备序列号
+	 */
+	@ApiModelProperty(value = "设备序列号")
+	private String eqSn;
 	/**
 	 * 产品图片
 	 */

+ 13 - 13
src/main/java/org/springblade/webSocket/server/WebSocketServer.java

@@ -62,8 +62,8 @@ public class WebSocketServer {
 		onlineSessionClientCount.incrementAndGet();
 		this.sid = sid;
 		this.session = session;
-		sendToOne(sid, "连接成功");
-		log.info("连接建立成功,当前在线数为:{} ==> 开始监听新连接:session_id = {}, sid = {},。", onlineSessionClientCount, session.getId(), sid);
+//		sendToOne(sid, "连接成功");
+		log.info("连接建立成功,当前在线数为:{} ==> 开始监听新连接:session_id = {}, sid = {}。", onlineSessionClientCount, session.getId(), sid);
 	}
 
 	/**
@@ -96,19 +96,19 @@ public class WebSocketServer {
 		 * html界面传递来得数据格式,可以自定义.
 		 * {"sid":"user-1","message":"hello websocket"}
 		 */
-		JSONObject jsonObject = JSON.parseObject(message);
-		String toSid = jsonObject.getString("sid");
-		String msg = jsonObject.getString("message");
-		log.info("服务端收到客户端消息 ==> fromSid = {}, toSid = {}, message = {}", sid, toSid, message);
+//		JSONObject jsonObject = JSON.parseObject(message);
+//		String toSid = jsonObject.getString("sid");
+//		String msg = jsonObject.getString("message");
+		log.info("服务端收到客户端消息 ==> fromSid = {}, message = {}", sid, message);
 
 		/**
 		 * 模拟约定:如果未指定sid信息,则群发,否则就单独发送
 		 */
-		if (toSid == null || toSid == "" || "".equalsIgnoreCase(toSid)) {
-			sendToAll(msg);
-		} else {
-			sendToOne(toSid, msg);
-		}
+//		if (toSid == null || toSid == "" || "".equalsIgnoreCase(toSid)) {
+//			sendToAll(msg);
+//		} else {
+//			sendToOne(toSid, msg);
+//		}
 	}
 
 	/**
@@ -132,10 +132,10 @@ public class WebSocketServer {
 		// 遍历在线map集合
 		onlineSessionClientMap.forEach((onlineSid, toSession) -> {
 			// 排除掉自己
-			if (!sid.equalsIgnoreCase(onlineSid)) {
+//			if (!sid.equalsIgnoreCase(onlineSid)) {
 				log.info("服务端给客户端群发消息 ==> sid = {}, toSid = {}, message = {}", sid, onlineSid, message);
 				toSession.getAsyncRemote().sendText(message);
-			}
+//			}
 		});
 	}
 

+ 1 - 0
src/main/resources/application.yml

@@ -230,6 +230,7 @@ blade:
     skip-url:
       - /blade-test/**
       - /pl/camera/api/**
+      - /app/api/**
     #授权认证配置
     auth:
       - method: ALL