|
@@ -2,10 +2,13 @@ package com.szwl.controller;
|
|
|
|
|
|
|
|
|
import cn.com.crbank.ommo.bean.ResultMessage;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.gexin.fastjson.JSON;
|
|
|
import com.szwl.model.entity.TEquipment;
|
|
|
import com.szwl.model.entity.TProduct;
|
|
|
+import com.szwl.model.utils.PushUtils;
|
|
|
import com.szwl.service.TEquipmentService;
|
|
|
import com.szwl.service.TProductService;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -14,11 +17,11 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -51,7 +54,88 @@ public class TProductController {
|
|
|
return ResponseEntity.status(HttpStatus.OK)
|
|
|
.body(new ResultMessage().setCode(true).setData(list).setMessage("SUCCESS"));
|
|
|
}
|
|
|
+ //修改花型是否显示
|
|
|
+ @ApiOperation(value = "修改花型是否显示")
|
|
|
+ @PostMapping("/updateProductsShow")
|
|
|
+ public ResponseEntity<?> updateProductsShow(@RequestBody String productList) {
|
|
|
|
|
|
-
|
|
|
+ List<TProduct> products = new ArrayList<>();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(productList);
|
|
|
+ products = JSONObject.parseArray(jsonObject.get("productList").toString(), TProduct.class);
|
|
|
+ if(products.size()>0){
|
|
|
+ TProduct tProduct = products.get(0);
|
|
|
+ if(tProduct==null&&tProduct.getEquipmentId()==null){
|
|
|
+ return ResponseEntity.status(HttpStatus.OK)
|
|
|
+ .body(new ResultMessage().setCode(false).setData("").setMessage("请退出重试"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ TEquipment equipment = tEquipmentService.getById(products.get(0).getEquipmentId());
|
|
|
+ if(equipment==null){
|
|
|
+ return ResponseEntity.status(HttpStatus.OK)
|
|
|
+ .body(new ResultMessage().setCode(false).setData("").setMessage("请退出重试"));
|
|
|
+ }
|
|
|
+ List<TProduct> list = new ArrayList<>();
|
|
|
+ for(TProduct product:products){
|
|
|
+ if(product!=null&&product.getId()!=null){
|
|
|
+// tProductService.updateById(product);
|
|
|
+ if(StringUtils.isEmpty(product.getShowType())){
|
|
|
+ product.setShowType("0");
|
|
|
+ }
|
|
|
+ product.setModifyDate(null);
|
|
|
+ product.setCreateDate(null);
|
|
|
+ product.setCodePrice(null);
|
|
|
+ product.setRmbPrice(null);
|
|
|
+ list.add(product);
|
|
|
+// tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("updateProductsShow", product.toString()).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("updateProductsShow", JSON.toJSONString(list)).toString());
|
|
|
+ return ResponseEntity.status(HttpStatus.OK)
|
|
|
+ .body(new ResultMessage().setCode(true).setData("").setMessage("修改成功"));
|
|
|
+ }
|
|
|
+ @ApiOperation(value = "/多个花型价格")
|
|
|
+ @GetMapping("/updateProduct")
|
|
|
+ public ResponseEntity<?> updateProduct(String no,String price,String equipmentId,String type) {
|
|
|
+ if(StringUtils.isEmpty(no)||StringUtils.isEmpty(price)||StringUtils.isEmpty(equipmentId)){
|
|
|
+ return ResponseEntity.status(HttpStatus.OK)
|
|
|
+ .body(new ResultMessage().setCode(false).setData("").setMessage("数据有空"));
|
|
|
+ }
|
|
|
+ TEquipment equipment = tEquipmentService.getById(equipmentId);
|
|
|
+ if(equipment==null){
|
|
|
+ return ResponseEntity.status(HttpStatus.OK)
|
|
|
+ .body(new ResultMessage().setCode(false).setData("").setMessage("请退出重试"));
|
|
|
+ }
|
|
|
+ //修改单个
|
|
|
+ if(type.equals("0")){
|
|
|
+ LambdaQueryWrapper<TProduct> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(TProduct::getEquipmentId,Long.valueOf(equipmentId));
|
|
|
+ query.eq(TProduct::getNo,no);
|
|
|
+ List<TProduct> list = tProductService.list(query);
|
|
|
+ if(list.size()>0){
|
|
|
+ TProduct product = list.get(0);
|
|
|
+ product.setModifyDate(new Date());
|
|
|
+ product.setCodePrice(new BigDecimal(price));
|
|
|
+ product.setRmbPrice(new BigDecimal(price));
|
|
|
+ tProductService.updateById(product);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //修改多个
|
|
|
+ if(type.equals("1")){
|
|
|
+ LambdaQueryWrapper<TProduct> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(TProduct::getEquipmentId,Long.valueOf(equipmentId));
|
|
|
+ List<TProduct> list = tProductService.list(query);
|
|
|
+ if(list.size()>0){
|
|
|
+ for(TProduct product:list){
|
|
|
+ product.setModifyDate(new Date());
|
|
|
+ product.setCodePrice(new BigDecimal(price) );
|
|
|
+ product.setRmbPrice(new BigDecimal(price) );
|
|
|
+ tProductService.updateById(product);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("updateProductsPrice", "0").toString());
|
|
|
+ return ResponseEntity.status(HttpStatus.OK)
|
|
|
+ .body(new ResultMessage().setCode(true).setData("").setMessage("修改成功"));
|
|
|
+ }
|
|
|
}
|
|
|
|