Commit 720102c6 by 丁伟峰

移除已经废弃的表product_category相关的代码

1 parent 891a70e6
package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.service.ProductCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/pea-order")
public class ProductCategoryController {
@Autowired
private ProductCategoryService productCategoryService;
@GetMapping("/product/category")
public Result<?> getProductCategory() {
Result<?> res = null;
try {
res = productCategoryService.getProductCategory();
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
}
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.ProductCategoryEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository
public interface ProductCategoryDao extends JpaRepository<ProductCategoryEntity, Long> {
ProductCategoryEntity getProductCategoryEntityByBrandAndTypeAndSkill(String brand, String type, String skill);
@Query("select p.layer from ProductCategoryEntity p where p.brand = :brand and p.type = :type and p.skill = :skill")
String getLayerByBrandAndTypeAndSkill(String brand, String type, String skill);
}
package com.dituhui.pea.order.dto;
import lombok.Data;
import java.util.List;
@Data
public class ProductCategoryResp {
private List<ProductCategory> categories;
@Data
public static class ProductCategory {
private String brand;
private String type;
private String skill;
private String categoryId;
}
}
package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import javax.persistence.*;
@Entity
@Data
@Table(name="product_category")
public class ProductCategoryEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 小组id
*/
private String productCategoryId;
/**
* 品牌
*/
private String brand;
/**
* 产品类别
*/
private String type;
/**
* 服务类型
*/
private String skill;
/**
* 所需工时(分钟)
*/
private Integer takeTime;
/**
* 所需人数
*/
private Integer takeEngineer;
/**
* 是否需要低压电工证
*/
private Integer lowElectricianCert;
/**
* 是否需要燃气证
*/
private Integer gasCert;
/**
* 图层标签
*/
private String layer;
/**
* 备注
*/
private String memo;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
public ProductCategoryEntity() {
}
}
package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result;
public interface ProductCategoryService {
Result<?> getProductCategory();
}
......@@ -23,14 +23,12 @@ import com.dituhui.pea.order.common.CapacityUtils;
import com.dituhui.pea.order.common.SaasUtils;
import com.dituhui.pea.order.dao.OrderRequestDao;
import com.dituhui.pea.order.dao.OrgTeamDao;
import com.dituhui.pea.order.dao.ProductCategoryDao;
import com.dituhui.pea.order.dto.LabelValueDTO;
import com.dituhui.pea.order.dto.LocationDTO;
import com.dituhui.pea.order.dto.OrderCreateReqDTO;
import com.dituhui.pea.order.dto.ParameterRespDTO;
import com.dituhui.pea.order.entity.OrderRequestEntity;
import com.dituhui.pea.order.entity.OrgTeamEntity;
import com.dituhui.pea.order.entity.ProductCategoryEntity;
import com.dituhui.pea.order.service.CommonService;
import com.dituhui.pea.order.service.OrderCreateService;
import io.seata.core.context.RootContext;
......@@ -55,9 +53,6 @@ public class OrderCreateServiceImpl implements OrderCreateService {
private OrderRequestDao orderRequestDao;
@Autowired
private ProductCategoryDao productCategoryDao;
@Autowired
private OrgTeamDao orgTeamDao;
@Autowired
......@@ -160,12 +155,6 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity.setAppointmentStatus("NOT_ASSIGNED");
entity.setAppointmentMethod("AUTO_NOW");
ProductCategoryEntity categoryEntity = productCategoryDao.getProductCategoryEntityByBrandAndTypeAndSkill(req.getBrand(), req.getType(), req.getSkill());
if (categoryEntity == null) {
throw new RuntimeException("产品代码不存在!");
}
String catalogId = categoryEntity.getProductCategoryId();
entity.setCategoryId(catalogId);
orderRequestDao.save(entity);
// 登记
commonService.addOrderEvent(orderId, "", req.getSource(), "API", "创建订单", "创建订单", "" );
......
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.ProductCategoryMPDao;
import com.dituhui.pea.order.dto.ProductCategoryResp;
import com.dituhui.pea.order.entity.ProductCategory;
import com.dituhui.pea.order.service.ProductCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class ProductCategoryServiceImpl implements ProductCategoryService {
@Autowired
private ProductCategoryMPDao productCategoryMPDao;
@Transactional
@Override
public Result<?> getProductCategory() {
// 查询所有记录
List<ProductCategory> records= productCategoryMPDao.selectList(null);
// 排序brand+type+skill
Comparator<ProductCategory> byBrand = Comparator.comparing(ProductCategory::getBrand);
Comparator<ProductCategory> byType = Comparator.comparing(ProductCategory::getType);
Comparator<ProductCategory> bySkill = Comparator.comparing(ProductCategory::getSkill);
Comparator<ProductCategory> comp = byBrand.thenComparing(byType).thenComparing(bySkill);
List<ProductCategory> results = records.stream().sorted(comp).collect(Collectors.toList());
ProductCategoryResp res = new ProductCategoryResp();
List<ProductCategoryResp.ProductCategory> categories = new ArrayList<>();
for (ProductCategory p: results) {
ProductCategoryResp.ProductCategory item = new ProductCategoryResp.ProductCategory();
item.setBrand(p.getBrand());
item.setType(p.getType());
item.setSkill(p.getSkill());
item.setCategoryId(p.getProductCategoryId());
categories.add(item);
}
res.setCategories(categories);
return Result.success(res);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!