wangdy 8 лет назад
Родитель
Сommit
86fdeaa76d

+ 14 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/dao/V_ProductPrivateDao.java

@@ -0,0 +1,14 @@
+package com.uas.platform.b2c.prod.commodity.dao;
+
+import com.uas.platform.b2c.prod.commodity.model.V_ProductPerson;
+import com.uas.platform.b2c.prod.commodity.model.V_ProductPersonId;
+import com.uas.platform.b2c.prod.commodity.model.V_ProductPrivate;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface V_ProductPrivateDao extends JpaRepository<V_ProductPrivate, Long>, JpaSpecificationExecutor<V_ProductPrivate> {
+}

+ 683 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/V_ProductPrivate.java

@@ -0,0 +1,683 @@
+package com.uas.platform.b2c.prod.commodity.model;
+
+import com.uas.platform.core.persistence.EnterpriseUU;
+import com.uas.platform.core.persistence.UserUU;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Set;
+
+@Entity
+@Table(name = "v$product$private")
+public class V_ProductPrivate implements Serializable {
+
+    /**
+     * products的主键
+     */
+    @Id
+    @Column(name = "pr_id")
+    private Long id;
+
+    /**
+     * 产品编号
+     * (b2b)code -> (b2c)prodNum
+     */
+    @Column(name = "pr_code")
+    private String prodNum;
+
+    /**
+     * 产品规格
+     */
+    @Column(name = "pr_spec", length = 500)
+    private String spec;
+
+    /**
+     * 单位
+     */
+    @Column(name = "pr_unit")
+    private String unit;
+
+    /**
+     * 所属企业UU
+     */
+    @Column(name = "pr_enuu")
+    @EnterpriseUU
+    private Long enUU;
+
+    /**
+     * 个人UU 上传人的UU
+     */
+    @Column(name = "pr_useruu")
+    @UserUU
+    private Long userUU;
+
+    /**
+     * 最小包装量
+     * (b2b)minPack -> (b2c)minPackQty
+     */
+    @Column(name = "pr_minpack")
+    private Double minPackQty;
+
+    /**
+     * 库存数 erp的库存数
+     */
+    @Column(name = "pr_stock")
+    private Double stock;
+
+    /**
+     * ERP空闲库存
+     */
+    @Column(name = "pr_reserve")
+    private Double erpReserve;
+
+    /**
+     * 价格
+     */
+    @Column(name = "pr_price")
+    private Double price;
+
+    /**
+     * 品牌(ERP) 上传时的品牌
+     */
+    @Column(name = "pr_brand")
+    private String brand;
+
+    /**
+     * 原厂型号(erp) 用户上传的型号
+     * @return
+     */
+    @Column(name = "pr_cmpcode", length = 1000)
+    private String cmpCode;
+
+    /**
+     * 产品名称
+     * (b2b)title -> (b2c)prodName
+     */
+    @Column(name = "pr_title")
+    private String prodName;
+
+    /**
+     * 买方ERP物料ID
+     */
+    @Column(name = "pr_sourceid")
+    private Long sourceId;
+
+    /**
+     * 保存erp传入数据的时间
+     *
+     * @return
+     */
+    @Column(name = "pr_erpdate")
+    private Date erpDate;
+
+    /**
+     * UUID 标准料号
+     * @return
+     */
+    @Column(name = "pr_cmpuuid")
+    private String cmpUuId;
+
+    /**
+     * 应用来源<br>
+     * 平台上传的为可以销售的
+     * @return
+     */
+    @Column(name = "pr_sourceapp")
+    private String sourceApp;
+
+
+    /**
+     * 类目(平台)(中文)
+     */
+    @Column(name = "pr_kind")
+    private String kind;
+
+    /**
+     * 类目(平台)(英文)
+     */
+    @Column(name = "pr_kinden")
+    private String kinden;
+
+    /**
+     * 类目的id
+     */
+    @Column(name = "pr_kindid")
+    private Long kindid;
+
+    /**
+     * 品牌(平台)(中文)
+     */
+    @Column(name = "pr_pbrand")
+    private String pbrand;
+
+    /**
+     * 品牌(平台)(英文)
+     */
+    @Column(name = "pr_pbranden")
+    private String pbranden;
+
+    /**
+     * 品牌(平台)id
+     */
+    @Column(name = "pr_pbrandid")
+    private Long pbrandid;
+
+    /**
+     * 品牌(平台)(uuid)
+     */
+    @Column(name = "pr_pbranduuid")
+    private String pbranduuid;
+
+    /**
+     * 型号(平台)
+     */
+    @Column(name = "pr_pcmpcode")
+    private String pcmpcode;
+    /**
+     * 是否是标准物料<br>
+     * 1.YES<br>
+     * 0.NO
+     */
+    @Column(name = "pr_standard")
+    private Integer standard;
+
+    /**
+     * 对应Goods是否已在售
+     * 1.YES<br>
+     * 0.NO
+     */
+    @Column(name = "pr_sold")
+    private Integer sold;
+
+    /**
+     * 是否可上架,是否有对应的Good信息
+     * 1.YES<br>
+     * 0.NO
+     */
+    @Column(name = "pr_can_sell")
+    private Integer canSell;
+
+    /**
+     * 匹配状态(记录匹配状态,方便下次查看)
+     * 111 匹配成功 ->变为标准
+     * 101 匹配之后没有更新,会存在多条数据
+     */
+    @Column(name = "pr_matchstatus")
+    private Integer matchstatus;
+
+    /**
+     * 匹配数量(用作排序)
+     */
+    @Column(name = "pr_matchsize")
+    private Integer matchsize;
+
+    /**
+     * 匹配结果
+     */
+    @OneToMany(mappedBy = "product", cascade = { CascadeType.REFRESH }, fetch = FetchType.EAGER)
+    private Set<ProductMatchResult> matchresults;
+
+    /**
+     * 封装
+     */
+    @Column(name = "pr_encapsulation")
+    private String encapsulation;
+
+    /**
+     * 包装:托盘、管装、卷带
+     */
+    @Column(name = "pr_packaging")
+    private String packaging;
+
+    /**
+     * 产品生产日期
+     */
+    @Column(name = "pr_manufacturedate")
+    private String produceDate;
+
+    /**
+     * 企业的币别信息
+     */
+    @Column(name = "pr_currency")
+    private String currency;
+
+    /**
+     * 在售数量
+     */
+    @Column(name = "pro_onsale")
+    private Double onSaleQty;
+
+    /**
+     * 锁库数
+     */
+    @Column(name = "pr_lockqty")
+    private Double lockQty;
+
+    /**
+     * 可上架数量
+     */
+    @Column(name = "pr_availableonsale")
+    private Double availableOnSale;
+
+    /**
+     * 仓库数量
+     */
+    @Column(name = "pr_repositoryqty")
+    private Double repositoryQty;
+
+    /**
+     * 器件的图片
+     */
+    @Column(name = "pr_comimg")
+    private String cmpImg;
+
+    /**
+     * b2c是否启用
+     * 1 启用,
+     * 0 未启用
+     */
+    @Column(name = "pr_b2cenabled")
+    private Integer b2cEnabled;
+
+    /**
+     * 产品建立时间
+     */
+    @Column(name = "pr_create_time")
+    private Date createTime;
+
+    /**
+     * 转成标准的时间
+     */
+    @Column(name = "pr_tostandard")
+    private Date tostandard;
+
+    /**
+     * b2c更新后下载状态
+     * DOWNLOADED(203, "已下载")
+     * NOT_UPLOAD(202, "待下载")
+     */
+    @Column(name = "pr_b2cdownstatus")
+    private Integer b2cDownStatus;
+
+    /**
+     * 针对erp的物料交易信息
+     */
+    @Transient
+    private ProductDetail productDetail;
+
+    /**
+     * goods表信息中存在多少条数据
+     */
+    @Column(name = "pr_batchcount")
+    private Integer batchCount;
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getProdNum() {
+        return prodNum;
+    }
+
+    public void setProdNum(String prodNum) {
+        this.prodNum = prodNum;
+    }
+
+    public String getSpec() {
+        return spec;
+    }
+
+    public void setSpec(String spec) {
+        this.spec = spec;
+    }
+
+    public String getUnit() {
+        return unit;
+    }
+
+    public void setUnit(String unit) {
+        this.unit = unit;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public Double getMinPackQty() {
+        return minPackQty;
+    }
+
+    public void setMinPackQty(Double minPackQty) {
+        this.minPackQty = minPackQty;
+    }
+
+    public Double getStock() {
+        return stock;
+    }
+
+    public void setStock(Double stock) {
+        this.stock = stock;
+    }
+
+    public Double getErpReserve() {
+        return erpReserve;
+    }
+
+    public void setErpReserve(Double erpReserve) {
+        this.erpReserve = erpReserve;
+    }
+
+    public Double getPrice() {
+        return price;
+    }
+
+    public void setPrice(Double price) {
+        this.price = price;
+    }
+
+    public String getBrand() {
+        return brand;
+    }
+
+    public void setBrand(String brand) {
+        this.brand = brand;
+    }
+
+    public String getCmpCode() {
+        return cmpCode;
+    }
+
+    public void setCmpCode(String cmpCode) {
+        this.cmpCode = cmpCode;
+    }
+
+    public String getProdName() {
+        return prodName;
+    }
+
+    public void setProdName(String prodName) {
+        this.prodName = prodName;
+    }
+
+    public Long getSourceId() {
+        return sourceId;
+    }
+
+    public void setSourceId(Long sourceId) {
+        this.sourceId = sourceId;
+    }
+
+    public Date getErpDate() {
+        return erpDate;
+    }
+
+    public void setErpDate(Date erpDate) {
+        this.erpDate = erpDate;
+    }
+
+    public String getCmpUuId() {
+        return cmpUuId;
+    }
+
+    public void setCmpUuId(String cmpUuId) {
+        this.cmpUuId = cmpUuId;
+    }
+
+    public String getSourceApp() {
+        return sourceApp;
+    }
+
+    public void setSourceApp(String sourceApp) {
+        this.sourceApp = sourceApp;
+    }
+
+    public String getKind() {
+        return kind;
+    }
+
+    public void setKind(String kind) {
+        this.kind = kind;
+    }
+
+    public String getKinden() {
+        return kinden;
+    }
+
+    public void setKinden(String kinden) {
+        this.kinden = kinden;
+    }
+
+    public Long getKindid() {
+        return kindid;
+    }
+
+    public void setKindid(Long kindid) {
+        this.kindid = kindid;
+    }
+
+    public String getPbrand() {
+        return pbrand;
+    }
+
+    public void setPbrand(String pbrand) {
+        this.pbrand = pbrand;
+    }
+
+    public String getPbranden() {
+        return pbranden;
+    }
+
+    public void setPbranden(String pbranden) {
+        this.pbranden = pbranden;
+    }
+
+    public Long getPbrandid() {
+        return pbrandid;
+    }
+
+    public void setPbrandid(Long pbrandid) {
+        this.pbrandid = pbrandid;
+    }
+
+    public String getPbranduuid() {
+        return pbranduuid;
+    }
+
+    public void setPbranduuid(String pbranduuid) {
+        this.pbranduuid = pbranduuid;
+    }
+
+    public String getPcmpcode() {
+        return pcmpcode;
+    }
+
+    public void setPcmpcode(String pcmpcode) {
+        this.pcmpcode = pcmpcode;
+    }
+
+    public Integer getStandard() {
+        return standard;
+    }
+
+    public void setStandard(Integer standard) {
+        this.standard = standard;
+    }
+
+    public Integer getSold() {
+        return sold;
+    }
+
+    public void setSold(Integer sold) {
+        this.sold = sold;
+    }
+
+    public Integer getCanSell() {
+        return canSell;
+    }
+
+    public void setCanSell(Integer canSell) {
+        this.canSell = canSell;
+    }
+
+    public Integer getMatchstatus() {
+        return matchstatus;
+    }
+
+    public void setMatchstatus(Integer matchstatus) {
+        this.matchstatus = matchstatus;
+    }
+
+    public Integer getMatchsize() {
+        return matchsize;
+    }
+
+    public void setMatchsize(Integer matchsize) {
+        this.matchsize = matchsize;
+    }
+
+    public Set<ProductMatchResult> getMatchresults() {
+        return matchresults;
+    }
+
+    public void setMatchresults(Set<ProductMatchResult> matchresults) {
+        this.matchresults = matchresults;
+    }
+
+    public String getEncapsulation() {
+        return encapsulation;
+    }
+
+    public void setEncapsulation(String encapsulation) {
+        this.encapsulation = encapsulation;
+    }
+
+    public String getPackaging() {
+        return packaging;
+    }
+
+    public void setPackaging(String packaging) {
+        this.packaging = packaging;
+    }
+
+    public String getProduceDate() {
+        return produceDate;
+    }
+
+    public void setProduceDate(String produceDate) {
+        this.produceDate = produceDate;
+    }
+
+    public String getCurrency() {
+        return currency;
+    }
+
+    public void setCurrency(String currency) {
+        this.currency = currency;
+    }
+
+    public Double getOnSaleQty() {
+        return onSaleQty;
+    }
+
+    public void setOnSaleQty(Double onSaleQty) {
+        this.onSaleQty = onSaleQty;
+    }
+
+    public Double getLockQty() {
+        return lockQty;
+    }
+
+    public void setLockQty(Double lockQty) {
+        this.lockQty = lockQty;
+    }
+
+    public Double getAvailableOnSale() {
+        return availableOnSale;
+    }
+
+    public void setAvailableOnSale(Double availableOnSale) {
+        this.availableOnSale = availableOnSale;
+    }
+
+    public Double getRepositoryQty() {
+        return repositoryQty;
+    }
+
+    public void setRepositoryQty(Double repositoryQty) {
+        this.repositoryQty = repositoryQty;
+    }
+
+    public String getCmpImg() {
+        return cmpImg;
+    }
+
+    public void setCmpImg(String cmpImg) {
+        this.cmpImg = cmpImg;
+    }
+
+    public Integer getB2cEnabled() {
+        return b2cEnabled;
+    }
+
+    public void setB2cEnabled(Integer b2cEnabled) {
+        this.b2cEnabled = b2cEnabled;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getTostandard() {
+        return tostandard;
+    }
+
+    public void setTostandard(Date tostandard) {
+        this.tostandard = tostandard;
+    }
+
+    public Integer getB2cDownStatus() {
+        return b2cDownStatus;
+    }
+
+    public void setB2cDownStatus(Integer b2cDownStatus) {
+        this.b2cDownStatus = b2cDownStatus;
+    }
+
+    public ProductDetail getProductDetail() {
+        return productDetail;
+    }
+
+    public void setProductDetail(ProductDetail productDetail) {
+        this.productDetail = productDetail;
+    }
+
+    public Integer getBatchCount() {
+        return batchCount;
+    }
+
+    public void setBatchCount(Integer batchCount) {
+        this.batchCount = batchCount;
+    }
+}

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/service/ProductService.java

@@ -24,7 +24,7 @@ public interface ProductService {
      * @param type    the type 标准or非标准
      * @return all products
      */
-    Page<Product> getAllProducts(PageInfo page, String keyword, String type);
+    Page<V_ProductPrivate> getAllProducts(PageInfo page, String keyword, String type);
 
     /**
      * 分页获取个人物料资料

+ 19 - 8
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -62,6 +62,7 @@ import org.springframework.jdbc.core.StatementCallback;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
+import org.springframework.web.client.RestTemplate;
 
 import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
@@ -104,6 +105,9 @@ public class ProductServiceImpl implements ProductService {
     @Autowired
     private GoodsDao goodsDao;
 
+    @Autowired
+    private RestTemplate restTemplate;
+
     @Autowired
     private CartDao cartDao;
 
@@ -146,6 +150,9 @@ public class ProductServiceImpl implements ProductService {
     @Autowired
     private V_ProductPersonDao v_productPersonDao;
 
+    @Autowired
+    private V_ProductPrivateDao v_productPrivateDao;
+
     @Autowired
     private OrderDetailDao orderDetailDao;
 
@@ -167,7 +174,7 @@ public class ProductServiceImpl implements ProductService {
     private ConcurrentHashMap<String, Field> sortFields = new ConcurrentHashMap<String, Field>();
 
     @Override
-    public Page<Product> getAllProducts(final PageInfo page, String keyword, String type) {
+    public Page<V_ProductPrivate> getAllProducts(final PageInfo page, String keyword, String type) {
         page.expression(PredicateUtils.eq("enUU", SystemSession.getUser().getEnterprise().getUu(), true));
         if (StringUtils.isEmpty(type)) {
             type = "nStandard";
@@ -199,15 +206,15 @@ public class ProductServiceImpl implements ProductService {
             page.expression(logicalExpression4);
         }
 
-        Page<Product> productPage = productDao.findAll(new Specification<Product>() {
+        Page<V_ProductPrivate> productPage = v_productPrivateDao.findAll(new Specification<V_ProductPrivate>() {
             @Override
-            public Predicate toPredicate(Root<Product> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
+            public Predicate toPredicate(Root<V_ProductPrivate> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
                 query.where(page.getPredicates(root, query, cb));
                 return null;
             }
         }, page);
-        List<Product> productList = productPage.getContent();
-        for (Product product : productList) {
+        List<V_ProductPrivate> productList = productPage.getContent();
+        for (V_ProductPrivate product : productList) {
             if ("ERP".equals(product.getSourceApp())) {
                 ProductDetail productDetail = productDetailDao.findByProductId(product.getId());
                 if (productDetail != null) {
@@ -222,7 +229,7 @@ public class ProductServiceImpl implements ProductService {
             }
         }
 
-        return new PageImpl<Product>(productList, page, productPage.getTotalElements());
+        return new PageImpl<V_ProductPrivate>(productList, page, productPage.getTotalElements());
     }
 
     @Override
@@ -341,8 +348,12 @@ public class ProductServiceImpl implements ProductService {
             if (null != isPerson && isPerson.intValue() == IntegerConstant.YES_SHORT.intValue()) {
                 List<ProductPerson> productPersonList = productPersonDao.findByProductIdAndUserUU(id,SystemSession.getUser().getUserUU());
                 if (!CollectionUtils.isEmpty(productPersonList)) {
-                    Long ppid = productPersonList.get(0).getId();
-                    productPersonDao.delete(ppid);
+                    Map<String,Object> requestMap = new HashMap<>();
+                    requestMap.put("userUU",productPersonList.get(0).getUserUU());
+                    requestMap.put("productId",productPersonList.get(0).getProductId());
+                    String res  = restTemplate.postForEntity("http://192.168.253.12:24000/product/assign/delete", null, String.class, requestMap).getBody();
+//                    Long ppid = productPersonList.get(0).getId();
+//                    productPersonDao.delete(ppid);
                 }
                 continue;
             }

+ 5 - 1
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -1141,8 +1141,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
         if (!CollectionUtils.isEmpty(releaseProductByBatchList)) {
             List<com.uas.ps.entity.Product> products = convertProduct(releaseProductByBatchList);
             // TODO 什么接口
-            String result = restTemplate.postForEntity("/update", products, String.class).getBody();
+			String result = restTemplate.postForEntity("http://192.168.253.12:24000/product/update", products, String.class).getBody();
             List<Long> productIds = JSON.parseArray(result, Long.class);
+            Map<String,Object> requestMap = new HashMap<>();
+            requestMap.put("userUU",SystemSession.getUser().getUserUU());
+            //添加个人关系
+            String res  = restTemplate.postForEntity("http://192.168.253.12:24000/product/assign/batch", productIds, String.class, requestMap).getBody();
             // 默认为b2c Enable开启
             List<ProductPrivate> productPrivates = new ArrayList<>();
             for (Long prId : productIds) {