|
@@ -26,6 +26,63 @@ public class ProductController {
|
|
|
@PostMapping("/save")
|
|
|
public ApiDTO save(@RequestBody @ApiParam(name = "SN规则对象", value = "传入json格式", required = true)Product product) {
|
|
|
|
|
|
+ // 针对产品规格这一项进行操作
|
|
|
+ if(product.getSnType().equals("产品规格")){
|
|
|
+
|
|
|
+ String[] SnTypeDescList = product.getSnTypeDesc().split(" ");
|
|
|
+ List<Product> productSpecification = new ArrayList<>();
|
|
|
+
|
|
|
+ String chemicalSystemCode = product.getSnTypeCode().substring(0,1);
|
|
|
+ String chemicalSystemDesc = SnTypeDescList[0];
|
|
|
+ String batteryPlatformCode = product.getSnTypeCode().substring(1,2);
|
|
|
+ String batteryPlatformDesc = SnTypeDescList[1];
|
|
|
+ String capacityCode = product.getSnTypeCode().substring(2,4);
|
|
|
+ String capacityDesc = SnTypeDescList[2];
|
|
|
+
|
|
|
+ Product chemicalSystem = new Product();
|
|
|
+ chemicalSystem.setSnType("化学体系");
|
|
|
+ chemicalSystem.setSnTypeCode(chemicalSystemCode);
|
|
|
+ chemicalSystem.setSnTypeDesc(chemicalSystemDesc);
|
|
|
+ chemicalSystem.setOperator(product.getOperator());
|
|
|
+ String checkSnTypeCodeResultOnChemicalSystem = VerifyUtil.checkSnTypeCode(chemicalSystem);
|
|
|
+ if(checkSnTypeCodeResultOnChemicalSystem.equals("passed")){
|
|
|
+ Product tmp_1 = productService.save(chemicalSystem);
|
|
|
+ productSpecification.add(tmp_1);}
|
|
|
+ else{
|
|
|
+ return ApiDTO.error(500,checkSnTypeCodeResultOnChemicalSystem);
|
|
|
+ }
|
|
|
+
|
|
|
+ Product batteryPlatform = new Product();
|
|
|
+ batteryPlatform.setSnType("电池平台");
|
|
|
+ batteryPlatform.setSnTypeCode(batteryPlatformCode);
|
|
|
+ batteryPlatform.setSnTypeDesc(batteryPlatformDesc);
|
|
|
+ batteryPlatform.setOperator(product.getOperator());
|
|
|
+ String checkSnTypeCodeResultOnBatteryPlatform = VerifyUtil.checkSnTypeCode(batteryPlatform);
|
|
|
+ if(checkSnTypeCodeResultOnBatteryPlatform.equals("passed")){
|
|
|
+ Product tmp_2 = productService.save(batteryPlatform);
|
|
|
+ productSpecification.add(tmp_2);}
|
|
|
+ else{
|
|
|
+ return ApiDTO.error(500,checkSnTypeCodeResultOnChemicalSystem);
|
|
|
+ }
|
|
|
+
|
|
|
+ Product capacity = new Product();
|
|
|
+ capacity.setSnType("容量");
|
|
|
+ capacity.setSnTypeCode(capacityCode);
|
|
|
+ capacity.setSnTypeDesc(capacityDesc);
|
|
|
+ capacity.setOperator(product.getOperator());
|
|
|
+ String checkSnTypeCodeResultOnCapacity = VerifyUtil.checkSnTypeCode(capacity);
|
|
|
+ if(checkSnTypeCodeResultOnCapacity.equals("passed")){
|
|
|
+ Product tmp_3 = productService.save(capacity);
|
|
|
+ productSpecification.add(tmp_3);}
|
|
|
+ else{
|
|
|
+ return ApiDTO.error(500,checkSnTypeCodeResultOnChemicalSystem);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return ApiDTO.ok("保存成功",productSpecification);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 校验输入的SN类型对应的编号
|
|
|
String checkSnTypeCodeResult = VerifyUtil.checkSnTypeCode(product);
|
|
|
|