diff --git a/src/main/java/com/glxp/udidl/admin/controller/device/UdiInfoController.java b/src/main/java/com/glxp/udidl/admin/controller/device/UdiInfoController.java index c6fcbfd..b86f24e 100644 --- a/src/main/java/com/glxp/udidl/admin/controller/device/UdiInfoController.java +++ b/src/main/java/com/glxp/udidl/admin/controller/device/UdiInfoController.java @@ -8,6 +8,7 @@ import com.glxp.udidl.admin.annotation.AuthRuleAnnotation; import com.glxp.udidl.admin.entity.udi.ProductInfoEntity; import com.glxp.udidl.admin.entity.udid.UdiEntity; import com.glxp.udidl.admin.req.FilterUdiInfoRequest; +import com.glxp.udidl.admin.req.MutiAppScanRequest; import com.glxp.udidl.admin.req.MutiScanRequest; import com.glxp.udidl.admin.req.ProductInfoFilterRequest; import com.glxp.udidl.admin.res.BaseResponse; @@ -21,6 +22,8 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; @@ -223,6 +226,111 @@ public class UdiInfoController { } + @PostMapping("udi/basic/app/mutilAppScan") + public BaseResponse mutilAppScan(@RequestBody MutiAppScanRequest mutiScanRequest) { + if (StrUtil.isEmpty(mutiScanRequest.getCode())) { + return ResultVOUtils.error(500, "条码不能为空!"); + } + String code = ""; + String originCode = ""; + List orginCodeArray = mutiScanRequest.getOriginCodeList(); + if (CollUtil.isNotEmpty(orginCodeArray)) { + for (String str : orginCodeArray) { + originCode = originCode + str; + } + } + code = originCode + mutiScanRequest.getCode(); + String newCode = mutiScanRequest.getCode(); + //重复判断 + if (StrUtil.isNotEmpty(originCode)) { + String tempOriginCode = originCode; + if (tempOriginCode.endsWith("\u001D")) { + tempOriginCode = tempOriginCode.replace("\u001D", ""); + } + UdiEntity originUdiEntity = FilterUdiUtils.getUdi(tempOriginCode); + if (StrUtil.isNotEmpty(newCode)) { + if (newCode.startsWith("10")) { + if (StrUtil.isNotEmpty(originUdiEntity.getBatchNo())) { + BaseResponse baseResponse = ResultVOUtils.error(501, "批次号重复添加"); + baseResponse.setData(orginCodeArray); + return baseResponse; + } else { + String msg = checkNewCode(originUdiEntity, newCode); + if (msg != null) { + BaseResponse baseResponse = ResultVOUtils.error(501, msg); + baseResponse.setData(orginCodeArray); + return baseResponse; + } + } + } else if (newCode.startsWith("17")) { + if (StrUtil.isNotEmpty(originUdiEntity.getExpireDate())) { + BaseResponse baseResponse = ResultVOUtils.error(501, "失效日期重复添加"); + baseResponse.setData(orginCodeArray); + return baseResponse; + } else { + String msg = checkNewCode(originUdiEntity, newCode); + if (msg != null) { + BaseResponse baseResponse = ResultVOUtils.error(501, msg); + baseResponse.setData(orginCodeArray); + return baseResponse; + } + } + } else if (newCode.startsWith("11")) { + if (StrUtil.isNotEmpty(originUdiEntity.getProduceDate())) { + BaseResponse baseResponse = ResultVOUtils.error(501, "生产日期重复添加"); + baseResponse.setData(orginCodeArray); + return baseResponse; + } else { + String msg = checkNewCode(originUdiEntity, newCode); + if (msg != null) { + BaseResponse baseResponse = ResultVOUtils.error(501, msg); + baseResponse.setData(orginCodeArray); + return baseResponse; + } + } + } else if (newCode.startsWith("21")) { + if (StrUtil.isNotEmpty(originUdiEntity.getSerialNo())) { + BaseResponse baseResponse = ResultVOUtils.error(501, "序列号重复添加"); + baseResponse.setData(orginCodeArray); + return baseResponse; + } else { + String msg = checkNewCode(originUdiEntity, newCode); + if (msg != null) { + BaseResponse baseResponse = ResultVOUtils.error(501, msg); + baseResponse.setData(orginCodeArray); + return baseResponse; + } + } + } else { + BaseResponse baseResponse = ResultVOUtils.error(501, "格式错误"); + baseResponse.setData(orginCodeArray); + return baseResponse; + } + } + } + + UdiEntity udiEntity = FilterUdiUtils.getUdi(code); + if (udiEntity == null) { + BaseResponse baseResponse = ResultVOUtils.error(501, "UDI码格式错误"); + baseResponse.setData(orginCodeArray); + return baseResponse; + } + if (StrUtil.isNotEmpty(udiEntity.getBatchNo())) { + if (code.endsWith("10" + udiEntity.getBatchNo())) { + code = code + "\u001D"; + } + } + + List result = new ArrayList<>(); + if (CollUtil.isNotEmpty(orginCodeArray)) + result.addAll(orginCodeArray); + String resultCode = code.substring(originCode.length()); + result.add(resultCode); + return ResultVOUtils.success(result); + + } + + public String checkNewCode(UdiEntity originEnity, String newCode) { UdiEntity newEntity = FilterUdiUtils.getUdi(originEnity.getUdi() + newCode); if (newEntity == null || originEnity == null) { diff --git a/src/main/java/com/glxp/udidl/admin/req/MutiAppScanRequest.java b/src/main/java/com/glxp/udidl/admin/req/MutiAppScanRequest.java new file mode 100644 index 0000000..0d1cc83 --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/req/MutiAppScanRequest.java @@ -0,0 +1,12 @@ +package com.glxp.udidl.admin.req; + +import lombok.Data; + +import java.util.List; + +@Data +public class MutiAppScanRequest { + String code; + List originCodeList; + +} diff --git a/src/main/java/com/glxp/udidl/admin/req/MutiScanRequest.java b/src/main/java/com/glxp/udidl/admin/req/MutiScanRequest.java index 67cf353..40f2134 100644 --- a/src/main/java/com/glxp/udidl/admin/req/MutiScanRequest.java +++ b/src/main/java/com/glxp/udidl/admin/req/MutiScanRequest.java @@ -2,10 +2,14 @@ package com.glxp.udidl.admin.req; import lombok.Data; +import java.util.List; + @Data public class MutiScanRequest { String code; String originCode; + + }