Browse Source

采美百科标签库关联

zhijiezhao 2 years ago
parent
commit
fe3b14787f

+ 18 - 1
src/main/java/com/caimei/modules/baike/entity/CmBaikeProduct.java

@@ -51,9 +51,26 @@ public class CmBaikeProduct extends DataEntity<CmBaikeProduct> {
 	private Integer recommendType;	//推荐类型:1手动推荐,2自动推荐
 	private Integer emptyNum;	//空数据条数
 	private Date addTime;		// 添加时间
-
+	private String labelIds;  //关联标签库ids
+	private String labelStr; //关联标签库
 	private String  referenceImgUrl;
 
+	public String getLabelStr() {
+		return labelStr;
+	}
+
+	public void setLabelStr(String labelStr) {
+		this.labelStr = labelStr;
+	}
+
+	public String getLabelIds() {
+		return labelIds;
+	}
+
+	public void setLabelIds(String labelIds) {
+		this.labelIds = labelIds;
+	}
+
 	public String getReferenceImgUrl() {
 		return referenceImgUrl;
 	}

+ 366 - 344
src/main/java/com/caimei/modules/baike/service/CmBaikeProductService.java

@@ -8,6 +8,7 @@ import com.caimei.modules.archive.entity.CmOrderArchiveFile;
 import com.caimei.modules.archive.utils.OssArchiveUtil;
 import com.caimei.modules.baike.dao.CmBaikeProductRecommendDao;
 import com.caimei.modules.baike.entity.*;
+import com.caimei.modules.basesetting.dao.KeywordDao;
 import com.caimei.modules.info.entity.Info;
 import com.caimei.modules.miniprogram.utils.UploadPicUtils;
 import com.caimei.modules.oss.utils.OSSUtils;
@@ -25,20 +26,24 @@ import javax.annotation.Resource;
 
 /**
  * 采美百科产品/仪器Service
+ *
  * @author Aslee
  * @version 2021-11-19
  */
 @Service
 @Transactional(readOnly = true)
 public class CmBaikeProductService extends CrudService<CmBaikeProductDao, CmBaikeProduct> {
-	@Resource
-	private CmBaikeProductDao cmBaikeProductDao;
+    @Resource
+    private CmBaikeProductDao cmBaikeProductDao;
 
-	@Resource
-	private CmBaikeProductRecommendDao cmBaikeProductRecommendDao;
+    @Resource
+    private CmBaikeProductRecommendDao cmBaikeProductRecommendDao;
 
-	public CmBaikeProduct get(String id) {
-		CmBaikeProduct cmBaikeProduct = super.get(id);
+    @Resource
+    private KeywordDao keywordDao;
+
+    public CmBaikeProduct get(String id) {
+        CmBaikeProduct cmBaikeProduct = super.get(id);
 //		String marketTime = cmBaikeProduct.getMarketTime();
 //		if (StringUtils.isNotEmpty(marketTime)) {
 //			String[] split = marketTime.split("-");
@@ -76,85 +81,100 @@ public class CmBaikeProductService extends CrudService<CmBaikeProductDao, CmBaik
 //			}
 //
 //		}
-		return cmBaikeProduct;
-	}
-	
-	public List<CmBaikeProduct> findList(CmBaikeProduct cmBaikeProduct) {
-		return super.findList(cmBaikeProduct);
-	}
-	
-	public Page<CmBaikeProduct> findPage(Page<CmBaikeProduct> page, CmBaikeProduct cmBaikeProduct) {
-		return super.findPage(page, cmBaikeProduct);
-	}
-	@Transactional(readOnly = false)
-	public void saveMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
-		cmBaikeProductDao.saveMaterialinfo(cmBaikeReferenceInfo);
-
-	}
-	@Transactional(readOnly = false)
-	public void upMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
-		cmBaikeProductDao.upMaterialinfo(cmBaikeReferenceInfo);
-
-	}
-
-	@Transactional(readOnly = false)
-	public void delMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
-		cmBaikeProductDao.delMaterialinfo(cmBaikeReferenceInfo);
-
-	}
-	@Transactional(readOnly = false)
-	public CmBaikeReferenceInfo getMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
-		return cmBaikeProductDao.getMaterialinfo(cmBaikeReferenceInfo);
-
-	}
-
-
-	@Transactional(readOnly = false)
-	public void save(CmBaikeProduct cmBaikeProduct) {
-		// 保存商品图片
-		String mainImage = cmBaikeProduct.getImage();
-		if (StringUtils.isNotEmpty(mainImage) && !mainImage.startsWith("http:")) {
-			cmBaikeProduct.setImage(UploadPicUtils.saveImageToServer(mainImage));
-		}
-		// 保存正品认证二维码
+        return cmBaikeProduct;
+    }
+
+    public List<CmBaikeProduct> findList(CmBaikeProduct cmBaikeProduct) {
+        return super.findList(cmBaikeProduct);
+    }
+
+    public Page<CmBaikeProduct> findPage(Page<CmBaikeProduct> page, CmBaikeProduct cmBaikeProduct) {
+        return super.findPage(page, cmBaikeProduct);
+    }
+
+    @Transactional(readOnly = false)
+    public void saveMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
+        cmBaikeProductDao.saveMaterialinfo(cmBaikeReferenceInfo);
+
+    }
+
+    @Transactional(readOnly = false)
+    public void upMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
+        cmBaikeProductDao.upMaterialinfo(cmBaikeReferenceInfo);
+
+    }
+
+    @Transactional(readOnly = false)
+    public void delMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
+        cmBaikeProductDao.delMaterialinfo(cmBaikeReferenceInfo);
+
+    }
+
+    @Transactional(readOnly = false)
+    public CmBaikeReferenceInfo getMaterialinfo(CmBaikeReferenceInfo cmBaikeReferenceInfo) {
+        return cmBaikeProductDao.getMaterialinfo(cmBaikeReferenceInfo);
+
+    }
+
+
+    @Transactional(readOnly = false)
+    public void save(CmBaikeProduct cmBaikeProduct) {
+        // 保存商品图片
+        String mainImage = cmBaikeProduct.getImage();
+        if (StringUtils.isNotEmpty(mainImage) && !mainImage.startsWith("http:")) {
+            cmBaikeProduct.setImage(UploadPicUtils.saveImageToServer(mainImage));
+        }
+        // 保存正品认证二维码
 //		String authQrCode = cmBaikeProduct.getAuthQrCode();
 //		if (StringUtils.isNotEmpty(authQrCode) && !authQrCode.startsWith("http:")) {
 //			cmBaikeProduct.setAuthQrCode(UploadPicUtils.saveImageToServer(authQrCode));
 //		}
-		// 删除原先的图片/参数/问题数据
-		if (!cmBaikeProduct.getIsNewRecord()) {
-			cmBaikeProductDao.deleteParamsByProductId(cmBaikeProduct.getId());
-			cmBaikeProductDao.deleteImagesByProductId(cmBaikeProduct.getId());
-			cmBaikeProductDao.delMaterialinfoBYProductId(cmBaikeProduct.getId());
-			cmBaikeProductDao.delTextListByEntryId(cmBaikeProduct.getId());//正文
-
-		}
-		// 保存上市时间和nmpa时间
+        // 删除原先的图片/参数/问题数据
+        if (!cmBaikeProduct.getIsNewRecord()) {
+            cmBaikeProductDao.deleteParamsByProductId(cmBaikeProduct.getId());
+            cmBaikeProductDao.deleteImagesByProductId(cmBaikeProduct.getId());
+            cmBaikeProductDao.delMaterialinfoBYProductId(cmBaikeProduct.getId());
+            cmBaikeProductDao.delTextListByEntryId(cmBaikeProduct.getId());//正文
+
+        }
+        // 保存上市时间和nmpa时间
 //		saveTime(cmBaikeProduct);
 
-		// 管理员审核百科
-		if (null != cmBaikeProduct.getAuditFlag() && 1 == cmBaikeProduct.getAuditFlag()) {
+        // 管理员审核百科
+        if (null != cmBaikeProduct.getAuditFlag() && 1 == cmBaikeProduct.getAuditFlag()) {
             cmBaikeProduct.setOnlineStatus(3);
             if (null != cmBaikeProduct.getAuditStatus() && 2 == cmBaikeProduct.getAuditStatus()) {
                 // 审核通过
                 cmBaikeProduct.setOnlineStatus(2);
                 cmBaikeProduct.setPublishTime(new Date());
             }
-		}
-		super.save(cmBaikeProduct);
-		String fileIds = cmBaikeProduct.getFileIds();
-		if (StringUtils.isNotEmpty(fileIds)) {
-			for (String id : fileIds.split(",")) {
-				if (StringUtil.isNotBlank(id)) {
-					cmBaikeProductDao.updateProductFile(Integer.valueOf(id),Integer.valueOf(cmBaikeProduct.getId()));
-				}
-			}
-		}
-		if (null != cmBaikeProduct.getAuditFlag() && 1 == cmBaikeProduct.getAuditFlag()) {
-			Integer emptyNum = checkComplete(cmBaikeProduct);
-			cmBaikeProductDao.updateEmptyNum(cmBaikeProduct.getId(), emptyNum);
-		}
-		String productId = cmBaikeProduct.getId();
+        }
+        // 标签
+        String[] labelIds = StringUtils.split(cmBaikeProduct.getLabelIds(), ",");
+        String labelStr = "";
+        if (null != labelIds && labelIds.length > 0) {
+            for (int i = 0; i < labelIds.length; i++) {
+                labelStr += keywordDao.findKeyWordId(labelIds[i]);
+                if (i != 5) {
+                    labelStr += "##";
+                }
+            }
+        }
+        cmBaikeProduct.setLabelStr(labelStr);
+        super.save(cmBaikeProduct);
+        String fileIds = cmBaikeProduct.getFileIds();
+        if (StringUtils.isNotEmpty(fileIds)) {
+            for (String id : fileIds.split(",")) {
+                if (StringUtil.isNotBlank(id)) {
+                    cmBaikeProductDao.updateProductFile(Integer.valueOf(id), Integer.valueOf(cmBaikeProduct.getId()));
+                }
+            }
+        }
+        if (null != cmBaikeProduct.getAuditFlag() && 1 == cmBaikeProduct.getAuditFlag()) {
+            Integer emptyNum = checkComplete(cmBaikeProduct);
+            cmBaikeProductDao.updateEmptyNum(cmBaikeProduct.getId(), emptyNum);
+        }
+        String productId = cmBaikeProduct.getId();
 //		// 保存产品认证图片
 //		List<String> authImageList = cmBaikeProduct.getAuthImageList();
 //		authImageList.forEach(authImage->{
@@ -165,292 +185,294 @@ public class CmBaikeProductService extends CrudService<CmBaikeProductDao, CmBaik
 //				cmBaikeProductDao.insertProductImage(authImage, productId, 1);
 //			}
 //		});
-		// 保存效果展示图片
-		List<String> displayImageList = cmBaikeProduct.getDisplayImageList();
-		displayImageList.forEach(displayImage->{
-			if (StringUtils.isNotEmpty(displayImage)) {
-				if (!displayImage.startsWith("http")) {
-					displayImage = UploadPicUtils.saveImageToServer(displayImage);
-				}
-				cmBaikeProductDao.insertProductImage(displayImage, productId, 2);
-			}
-		});
-		// 保存参数
-		List<CmBaikeProductParam> paramList = cmBaikeProduct.getParamList();
-		if(null!=paramList&&paramList.size()>0){
-			paramList.forEach(param->{
-				if (StringUtils.isNotEmpty(param.getName()) && StringUtils.isNotEmpty(param.getContent())) {
-					cmBaikeProductDao.insertProductParam(param.getName(), param.getContent(), productId);
-				}
-			});
-		}
-		//保存资料
-		List<CmBaikeReferenceInfo> cmBaikeReferenceInfo = cmBaikeProduct.getMaterialInfo();
-		if(null!=cmBaikeReferenceInfo&&cmBaikeReferenceInfo.size()>0){
-		cmBaikeReferenceInfo.forEach(param->{
-			if(null!=param){
-				if(null==param.getPublicationYear()||" ".equals(param.getPublicationYear())){
-					param.setPublicationYear(null);
-				}
-				if(org.apache.commons.lang.StringUtils.isEmpty(param.getPublicationYearStr())||" ".equals(param.getPublicationYearStr())){
-					param.setPublicationYearStr(null);
-				}
-				if(null==param.getPublishTime()){
-					param.setPublishTime(null);
-				}
-				if(org.apache.commons.lang.StringUtils.isEmpty(param.getPublishTimeStr())||" ".equals(param.getPublishTimeStr())){
-					param.setPublishTimeStr(null);
-				}
-				if(null==param.getAcitationTime()){
-					param.setAcitationTime(null);
-				}
-				if(org.apache.commons.lang.StringUtils.isEmpty(param.getAcitationTimeStr())||" ".equals(param.getAcitationTimeStr())){
-					param.setAcitationTimeStr(null);
-				}
-			}
-				param.setProductId(Integer.valueOf(productId));
-				cmBaikeProductDao.saveMaterialinfo(param);
-		});
-		}
-		//保存正文
-		List<CmBaikeTextInfo> textInfolist = cmBaikeProduct.getTextInfolist();
-		if(null!=textInfolist&&textInfolist.size()>0){
-			textInfolist.forEach(param->{
-				param.setProductId(productId);
-				cmBaikeProductDao.insertText(param);
-			});
-		}
-		// 保存问题
+        // 保存效果展示图片
+        List<String> displayImageList = cmBaikeProduct.getDisplayImageList();
+        displayImageList.forEach(displayImage -> {
+            if (StringUtils.isNotEmpty(displayImage)) {
+                if (!displayImage.startsWith("http")) {
+                    displayImage = UploadPicUtils.saveImageToServer(displayImage);
+                }
+                cmBaikeProductDao.insertProductImage(displayImage, productId, 2);
+            }
+        });
+        // 保存参数
+        List<CmBaikeProductParam> paramList = cmBaikeProduct.getParamList();
+        if (null != paramList && paramList.size() > 0) {
+            paramList.forEach(param -> {
+                if (StringUtils.isNotEmpty(param.getName()) && StringUtils.isNotEmpty(param.getContent())) {
+                    cmBaikeProductDao.insertProductParam(param.getName(), param.getContent(), productId);
+                }
+            });
+        }
+        //保存资料
+        List<CmBaikeReferenceInfo> cmBaikeReferenceInfo = cmBaikeProduct.getMaterialInfo();
+        if (null != cmBaikeReferenceInfo && cmBaikeReferenceInfo.size() > 0) {
+            cmBaikeReferenceInfo.forEach(param -> {
+                if (null != param) {
+                    if (null == param.getPublicationYear() || " ".equals(param.getPublicationYear())) {
+                        param.setPublicationYear(null);
+                    }
+                    if (org.apache.commons.lang.StringUtils.isEmpty(param.getPublicationYearStr()) || " ".equals(param.getPublicationYearStr())) {
+                        param.setPublicationYearStr(null);
+                    }
+                    if (null == param.getPublishTime()) {
+                        param.setPublishTime(null);
+                    }
+                    if (org.apache.commons.lang.StringUtils.isEmpty(param.getPublishTimeStr()) || " ".equals(param.getPublishTimeStr())) {
+                        param.setPublishTimeStr(null);
+                    }
+                    if (null == param.getAcitationTime()) {
+                        param.setAcitationTime(null);
+                    }
+                    if (org.apache.commons.lang.StringUtils.isEmpty(param.getAcitationTimeStr()) || " ".equals(param.getAcitationTimeStr())) {
+                        param.setAcitationTimeStr(null);
+                    }
+                }
+                param.setProductId(Integer.valueOf(productId));
+                cmBaikeProductDao.saveMaterialinfo(param);
+            });
+        }
+        //保存正文
+        List<CmBaikeTextInfo> textInfolist = cmBaikeProduct.getTextInfolist();
+        if (null != textInfolist && textInfolist.size() > 0) {
+            textInfolist.forEach(param -> {
+                param.setProductId(productId);
+                cmBaikeProductDao.insertText(param);
+            });
+        }
+        // 保存问题
 //		List<CmBaikeProductQuestion> questionList = cmBaikeProduct.getQuestionList();
 //		questionList.forEach(question->{
 //			if (StringUtils.isNotEmpty(question.getQuestion()) && StringUtils.isNotEmpty(question.getAnswer())) {
 //				cmBaikeProductDao.insertProductQuestion(question.getQuestion(), question.getAnswer(), productId);
 //			}
 //		});
-	}
-
-	private void saveTime(CmBaikeProduct cmBaikeProduct) {
-		Integer marketYear = cmBaikeProduct.getMarketYear();
-		Integer marketMonth = cmBaikeProduct.getMarketMonth();
-		Integer marketDay = cmBaikeProduct.getMarketDay();
-		Integer nmpaYear = cmBaikeProduct.getNmpaYear();
-		Integer nmpaMonth = cmBaikeProduct.getNmpaMonth();
-		Integer nmpaDay = cmBaikeProduct.getNmpaDay();
-		String marketTime = "";
-		if (null != marketYear) {
-			marketTime += marketYear;
-			if (null != marketMonth) {
-				marketTime += "-" + (marketMonth < 10 ? "0" + marketMonth : marketMonth);
-				if (null != marketDay) {
-					marketTime += "-" + (marketDay < 10 ? "0" + marketDay : marketDay);
-				}
-			}
-		}
-		cmBaikeProduct.setMarketTime(marketTime);
-		String nmpaTime = "";
-		if (null != nmpaYear) {
-			nmpaTime += nmpaYear;
-			if (null != nmpaMonth) {
-				nmpaTime += "-" + (nmpaMonth < 10 ? "0" + nmpaMonth : nmpaMonth);
-				if (null != nmpaDay) {
-					nmpaTime += "-" + (nmpaDay < 10 ? "0" + nmpaDay : nmpaDay);
-				}
-			}
-		}
-		cmBaikeProduct.setNmpaTime(nmpaTime);
-	}
-
-	@Transactional(readOnly = false)
-	public void delete(CmBaikeProduct cmBaikeProduct) {
-		super.delete(cmBaikeProduct);
-	}
-
-	@Transactional(readOnly = false)
-	public void updateTopPosition(CmBaikeProduct cmBaikeProduct) {
-		cmBaikeProductDao.updateTopPosition(cmBaikeProduct);
-	}
-
-	/**
-	 * 清除置顶,将后面置顶位的数据往前移
-	 * @param cmBaikeProduct
-	 */
-	@Transactional(readOnly = false)
-	public void moveTopList(CmBaikeProduct cmBaikeProduct) {
-		Integer oldPosition = cmBaikeProduct.getTopPosition();
-		List<CmBaikeProduct> topCmBaikeProductList = findTopList();
-		topCmBaikeProductList.forEach(topCmBaikeProduct->{
-			Integer topPosition = topCmBaikeProduct.getTopPosition();
-			if (topPosition>oldPosition) {
-				topCmBaikeProduct.setTopPosition(--topPosition);
-				updateTopPosition(topCmBaikeProduct);
-			}
-		});
-	}
-
-	/**
-	 * 置顶商品列表
-	 * @return
-	 */
-	public List<CmBaikeProduct> findTopList() {
-		CmBaikeProduct cmBaikeProduct = new CmBaikeProduct();
-		cmBaikeProduct.setTopFlag(1);
-		return cmBaikeProductDao.findList(cmBaikeProduct);
-	}
-
-	@Transactional(readOnly = false)
-	public void auditBaike(CmBaikeProduct cmBaikeProduct) {
-		Date publishTime = null;
-		if (cmBaikeProduct.getAuditStatus() == 2) {
-			publishTime = new Date();
-		}
-		cmBaikeProductDao.auditBaike(cmBaikeProduct.getId(), cmBaikeProduct.getAuditStatus(), cmBaikeProduct.getFailReason(), publishTime);
-	}
+    }
+
+    private void saveTime(CmBaikeProduct cmBaikeProduct) {
+        Integer marketYear = cmBaikeProduct.getMarketYear();
+        Integer marketMonth = cmBaikeProduct.getMarketMonth();
+        Integer marketDay = cmBaikeProduct.getMarketDay();
+        Integer nmpaYear = cmBaikeProduct.getNmpaYear();
+        Integer nmpaMonth = cmBaikeProduct.getNmpaMonth();
+        Integer nmpaDay = cmBaikeProduct.getNmpaDay();
+        String marketTime = "";
+        if (null != marketYear) {
+            marketTime += marketYear;
+            if (null != marketMonth) {
+                marketTime += "-" + (marketMonth < 10 ? "0" + marketMonth : marketMonth);
+                if (null != marketDay) {
+                    marketTime += "-" + (marketDay < 10 ? "0" + marketDay : marketDay);
+                }
+            }
+        }
+        cmBaikeProduct.setMarketTime(marketTime);
+        String nmpaTime = "";
+        if (null != nmpaYear) {
+            nmpaTime += nmpaYear;
+            if (null != nmpaMonth) {
+                nmpaTime += "-" + (nmpaMonth < 10 ? "0" + nmpaMonth : nmpaMonth);
+                if (null != nmpaDay) {
+                    nmpaTime += "-" + (nmpaDay < 10 ? "0" + nmpaDay : nmpaDay);
+                }
+            }
+        }
+        cmBaikeProduct.setNmpaTime(nmpaTime);
+    }
+
+    @Transactional(readOnly = false)
+    public void delete(CmBaikeProduct cmBaikeProduct) {
+        super.delete(cmBaikeProduct);
+    }
+
+    @Transactional(readOnly = false)
+    public void updateTopPosition(CmBaikeProduct cmBaikeProduct) {
+        cmBaikeProductDao.updateTopPosition(cmBaikeProduct);
+    }
+
+    /**
+     * 清除置顶,将后面置顶位的数据往前移
+     *
+     * @param cmBaikeProduct
+     */
+    @Transactional(readOnly = false)
+    public void moveTopList(CmBaikeProduct cmBaikeProduct) {
+        Integer oldPosition = cmBaikeProduct.getTopPosition();
+        List<CmBaikeProduct> topCmBaikeProductList = findTopList();
+        topCmBaikeProductList.forEach(topCmBaikeProduct -> {
+            Integer topPosition = topCmBaikeProduct.getTopPosition();
+            if (topPosition > oldPosition) {
+                topCmBaikeProduct.setTopPosition(--topPosition);
+                updateTopPosition(topCmBaikeProduct);
+            }
+        });
+    }
+
+    /**
+     * 置顶商品列表
+     *
+     * @return
+     */
+    public List<CmBaikeProduct> findTopList() {
+        CmBaikeProduct cmBaikeProduct = new CmBaikeProduct();
+        cmBaikeProduct.setTopFlag(1);
+        return cmBaikeProductDao.findList(cmBaikeProduct);
+    }
+
+    @Transactional(readOnly = false)
+    public void auditBaike(CmBaikeProduct cmBaikeProduct) {
+        Date publishTime = null;
+        if (cmBaikeProduct.getAuditStatus() == 2) {
+            publishTime = new Date();
+        }
+        cmBaikeProductDao.auditBaike(cmBaikeProduct.getId(), cmBaikeProduct.getAuditStatus(), cmBaikeProduct.getFailReason(), publishTime);
+    }
 
     @Transactional(readOnly = false)
     public void offlineInfo(Integer id) {
         cmBaikeProductDao.offline(id);
     }
 
-	public Integer checkComplete(CmBaikeProduct product) {
-		String productId = product.getId();
-		// 参数列表
-		List<CmBaikeProductParam> paramList = cmBaikeProductDao.findParamList(productId);
-		// 产品/仪器认证图片列表
-		List<String> authImageList = cmBaikeProductDao.findImageList(productId, 1);
-		// 效果展示图片列表
-		List<String> displayImageList = cmBaikeProductDao.findImageList(productId, 2);
-		// 问题列表
-		List<CmBaikeProductQuestion> questionList = cmBaikeProductDao.findQuestionList(productId);
-		Integer emptyNum = 0;
-		List<String> propertyList1 = new ArrayList<>();
-		List<Integer> propertyList2 = new ArrayList<>();
-		propertyList1.add(product.getName());
-		propertyList1.add(product.getAlias());
-		propertyList1.add(product.getDiscription());
-		propertyList1.add(product.getProductLink());
-		propertyList1.add(product.getImage());
-		if (2 == product.getCommodityType()) {
-			propertyList1.add(product.getAuthLink());
-			propertyList1.add(product.getAuthQrCode());
-		}
-		propertyList1.add(product.getAdvantage());
-		propertyList1.add(product.getDisadvantage());
-		propertyList1.add(product.getPrinciple());
-		propertyList1.add(product.getSeoKeyword());
-		propertyList1.add(product.getBrand());
-		propertyList1.add(product.getProducePlace());
-		propertyList1.add(product.getMarketTime());
-		propertyList1.add(product.getCompany());
-		propertyList1.add(product.getNmpaTime());
-		propertyList1.add(product.getAdaptiveMan());
-		propertyList1.add(product.getUnAdaptiveMan());
-		propertyList1.add(product.getAroundOperation());
-
-		propertyList2.add(product.getShopId());
-		propertyList2.add(product.getBasePv());
-		propertyList2.add(product.getTypeId());
-		for (String property : propertyList1) {
-			if (StringUtils.isEmpty(property)) {
-				emptyNum++;
-			}
-		}
-		for (Integer property : propertyList2) {
-			if (null == property) {
-				emptyNum++;
-			}
-		}
-		if (null == product.getPublishTime()) {
-			emptyNum++;
-		}
-		if (0 == paramList.size()) {
-			emptyNum++;
-		}
-		if (0 == authImageList.size()) {
-			emptyNum++;
-		}
-		if (0 == displayImageList.size()) {
-			emptyNum++;
-		}
-		if (0 == questionList.size()) {
-			emptyNum++;
-		}
-		return emptyNum;
-	}
-
-	@Transactional(readOnly = false)
-    public Map<String, Object> upload(MultipartFile multipartFile,String fileTitle, String fileName, Integer productId, String fileIds) {
-		Map<String, Object> map = new HashMap<>();
-		if (null != productId || StringUtils.isNotEmpty(fileIds)) {
-			Integer fileIdByFileName = cmBaikeProductDao.checkFileName(fileName, productId, fileIds);
-			if (null != fileIdByFileName) {
-				map.put("success", false);
-				map.put("msg", "文件已存在");
-				return map;
-			}
-		}
-		String fileAllName = multipartFile.getOriginalFilename();
-		String fileType = fileAllName.substring(fileAllName.lastIndexOf(".") + 1);
-		String uuid = UUID.randomUUID().toString().replaceAll("-", "");
-		String filePath = uuid + "." + fileType;
-		String contentType = OssArchiveUtil.getContentType(fileAllName);
-		try {
-			//保存本地
-			File file = OSSUtils.ossUpload(multipartFile);
-			logger.info("默认路径>>>" + file.getAbsolutePath());
-			//上传oss
-			String url = OSSUtils.ossUpload(filePath, file, contentType);
-			//删除本地文件
-			OssArchiveUtil.deleteFile(file);
-			//保存关联关系
-			CmBaikeProductFile productFile = new CmBaikeProductFile();
-			productFile.setFileTitle(fileTitle);
-			productFile.setFileName(fileName);
-			productFile.setOssName(filePath);
-			productFile.setOssUrl(url);
-			cmBaikeProductDao.insertProductFile(productFile);
-			productFile.setOssUrl(url);
-			map.put("success", true);
-			map.put("msg", "操作成功");
-			map.put("productFile", productFile);
-		} catch (Exception e) {
-			e.printStackTrace();
-			map.put("success", false);
-			map.put("msg", "操作失败");
-			logger.info("上传异常!!!");
-		}
-		return map;
+    public Integer checkComplete(CmBaikeProduct product) {
+        String productId = product.getId();
+        // 参数列表
+        List<CmBaikeProductParam> paramList = cmBaikeProductDao.findParamList(productId);
+        // 产品/仪器认证图片列表
+        List<String> authImageList = cmBaikeProductDao.findImageList(productId, 1);
+        // 效果展示图片列表
+        List<String> displayImageList = cmBaikeProductDao.findImageList(productId, 2);
+        // 问题列表
+        List<CmBaikeProductQuestion> questionList = cmBaikeProductDao.findQuestionList(productId);
+        Integer emptyNum = 0;
+        List<String> propertyList1 = new ArrayList<>();
+        List<Integer> propertyList2 = new ArrayList<>();
+        propertyList1.add(product.getName());
+        propertyList1.add(product.getAlias());
+        propertyList1.add(product.getDiscription());
+        propertyList1.add(product.getProductLink());
+        propertyList1.add(product.getImage());
+        if (2 == product.getCommodityType()) {
+            propertyList1.add(product.getAuthLink());
+            propertyList1.add(product.getAuthQrCode());
+        }
+        propertyList1.add(product.getAdvantage());
+        propertyList1.add(product.getDisadvantage());
+        propertyList1.add(product.getPrinciple());
+        propertyList1.add(product.getSeoKeyword());
+        propertyList1.add(product.getBrand());
+        propertyList1.add(product.getProducePlace());
+        propertyList1.add(product.getMarketTime());
+        propertyList1.add(product.getCompany());
+        propertyList1.add(product.getNmpaTime());
+        propertyList1.add(product.getAdaptiveMan());
+        propertyList1.add(product.getUnAdaptiveMan());
+        propertyList1.add(product.getAroundOperation());
+
+        propertyList2.add(product.getShopId());
+        propertyList2.add(product.getBasePv());
+        propertyList2.add(product.getTypeId());
+        for (String property : propertyList1) {
+            if (StringUtils.isEmpty(property)) {
+                emptyNum++;
+            }
+        }
+        for (Integer property : propertyList2) {
+            if (null == property) {
+                emptyNum++;
+            }
+        }
+        if (null == product.getPublishTime()) {
+            emptyNum++;
+        }
+        if (0 == paramList.size()) {
+            emptyNum++;
+        }
+        if (0 == authImageList.size()) {
+            emptyNum++;
+        }
+        if (0 == displayImageList.size()) {
+            emptyNum++;
+        }
+        if (0 == questionList.size()) {
+            emptyNum++;
+        }
+        return emptyNum;
     }
 
-	@Transactional(readOnly = false)
-	public void deleteFile(Integer fileId) {
-		CmBaikeProductFile productFile = cmBaikeProductDao.getProductFileById(fileId);
-		if (productFile != null) {
-			//删除oss服务器上的文件
-			OSSUtils.deleteSingleFile(productFile.getOssName());
-			cmBaikeProductDao.deleteProductFile(fileId);
-		}
-	}
+    @Transactional(readOnly = false)
+    public Map<String, Object> upload(MultipartFile multipartFile, String fileTitle, String fileName, Integer productId, String fileIds) {
+        Map<String, Object> map = new HashMap<>();
+        if (null != productId || StringUtils.isNotEmpty(fileIds)) {
+            Integer fileIdByFileName = cmBaikeProductDao.checkFileName(fileName, productId, fileIds);
+            if (null != fileIdByFileName) {
+                map.put("success", false);
+                map.put("msg", "文件已存在");
+                return map;
+            }
+        }
+        String fileAllName = multipartFile.getOriginalFilename();
+        String fileType = fileAllName.substring(fileAllName.lastIndexOf(".") + 1);
+        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+        String filePath = uuid + "." + fileType;
+        String contentType = OssArchiveUtil.getContentType(fileAllName);
+        try {
+            //保存本地
+            File file = OSSUtils.ossUpload(multipartFile);
+            logger.info("默认路径>>>" + file.getAbsolutePath());
+            //上传oss
+            String url = OSSUtils.ossUpload(filePath, file, contentType);
+            //删除本地文件
+            OssArchiveUtil.deleteFile(file);
+            //保存关联关系
+            CmBaikeProductFile productFile = new CmBaikeProductFile();
+            productFile.setFileTitle(fileTitle);
+            productFile.setFileName(fileName);
+            productFile.setOssName(filePath);
+            productFile.setOssUrl(url);
+            cmBaikeProductDao.insertProductFile(productFile);
+            productFile.setOssUrl(url);
+            map.put("success", true);
+            map.put("msg", "操作成功");
+            map.put("productFile", productFile);
+        } catch (Exception e) {
+            e.printStackTrace();
+            map.put("success", false);
+            map.put("msg", "操作失败");
+            logger.info("上传异常!!!");
+        }
+        return map;
+    }
+
+    @Transactional(readOnly = false)
+    public void deleteFile(Integer fileId) {
+        CmBaikeProductFile productFile = cmBaikeProductDao.getProductFileById(fileId);
+        if (productFile != null) {
+            //删除oss服务器上的文件
+            OSSUtils.deleteSingleFile(productFile.getOssName());
+            cmBaikeProductDao.deleteProductFile(fileId);
+        }
+    }
 
 
     @Transactional(readOnly = false)
-	public void saveRecommend(CmBaikeProduct cmBaikeProduct) {
-		cmBaikeProductDao.updateRecommendType(cmBaikeProduct.getId(), cmBaikeProduct.getRecommendType());
-		// 清除原来的推荐数据
-		if (1 == cmBaikeProduct.getRecommendType()) {
-			cmBaikeProductRecommendDao.clearRecommendData(cmBaikeProduct.getId());
-			String[] recommendParams = cmBaikeProduct.getRecommendParams();
-			int productId = Integer.parseInt(cmBaikeProduct.getId());
-			if (null != recommendParams && recommendParams.length > 0) {
-				for (int i = 0; i < recommendParams.length; i++) {
-					String recommendParam = recommendParams[i];
-					String[] split = recommendParam.split(":");
-					CmBaikeProductRecommend recommend = new CmBaikeProductRecommend();
-					recommend.setProductId(productId);
-					recommend.setRecommendProductId(Integer.parseInt(split[0]) );
-					recommend.setSort(Integer.parseInt(split[1]));
-					cmBaikeProductRecommendDao.insert(recommend);
-				}
-			}
-		}
-	}
+    public void saveRecommend(CmBaikeProduct cmBaikeProduct) {
+        cmBaikeProductDao.updateRecommendType(cmBaikeProduct.getId(), cmBaikeProduct.getRecommendType());
+        // 清除原来的推荐数据
+        if (1 == cmBaikeProduct.getRecommendType()) {
+            cmBaikeProductRecommendDao.clearRecommendData(cmBaikeProduct.getId());
+            String[] recommendParams = cmBaikeProduct.getRecommendParams();
+            int productId = Integer.parseInt(cmBaikeProduct.getId());
+            if (null != recommendParams && recommendParams.length > 0) {
+                for (int i = 0; i < recommendParams.length; i++) {
+                    String recommendParam = recommendParams[i];
+                    String[] split = recommendParam.split(":");
+                    CmBaikeProductRecommend recommend = new CmBaikeProductRecommend();
+                    recommend.setProductId(productId);
+                    recommend.setRecommendProductId(Integer.parseInt(split[0]));
+                    recommend.setSort(Integer.parseInt(split[1]));
+                    cmBaikeProductRecommendDao.insert(recommend);
+                }
+            }
+        }
+    }
 }

File diff suppressed because it is too large
+ 533 - 528
src/main/java/com/caimei/modules/baike/web/CmBaikeProductController.java


+ 26 - 15
src/main/resources/mappings/modules/baike/CmBaikeProductMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.modules.baike.dao.CmBaikeProductDao">
-    
+
 	<sql id="cmBaikeProductColumns">
 		a.id AS "id",
 		a.commodityType AS "commodityType",
@@ -38,24 +38,25 @@
 		a.failReason,
 		a.addTime AS "addTime",
 		a.recommendType,
-		cbt.name as "typeName"
+		cbt.name as "typeName",
+		a.labelIds as "labelIds"
 	</sql>
-	
+
 	<sql id="cmBaikeProductJoins">
 		left join cm_baike_type cbt on a.typeId = cbt.id
 		left join shop s on a.shopId = s.shopID
 	</sql>
-    
+
 	<select id="get" resultType="CmBaikeProduct">
-		SELECT 
+		SELECT
 			<include refid="cmBaikeProductColumns"/>
 		FROM cm_baike_product a
 		<include refid="cmBaikeProductJoins"/>
 		WHERE a.id = #{id} and delFlag = 0
 	</select>
-	
+
 	<select id="findList" resultType="CmBaikeProduct">
-		SELECT 
+		SELECT
 			<include refid="cmBaikeProductColumns"/>
 		FROM cm_baike_product a
 		<include refid="cmBaikeProductJoins"/>
@@ -65,7 +66,7 @@
 				AND a.id = #{id}
 			</if>
 			<if test="name != null and name != ''">
-				AND a.name LIKE 
+				AND a.name LIKE
 					<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
 					<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
 					<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
@@ -120,15 +121,15 @@
 			</otherwise>
 		</choose>
 	</select>
-	
+
 	<select id="findAllList" resultType="CmBaikeProduct">
-		SELECT 
+		SELECT
 			<include refid="cmBaikeProductColumns"/>
 		FROM cm_baike_product a
 		<include refid="cmBaikeProductJoins"/>
 		<where>
-			
-		</where>		
+
+		</where>
 		<choose>
 			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
 				ORDER BY ${page.orderBy}
@@ -215,7 +216,9 @@
 			typeId,
 			emptyNum,
 			status,
-			addTime
+			addTime,
+			labelIds,
+			relatedLabels
 		) VALUES (
 			#{commodityType},
 			#{name},
@@ -244,7 +247,9 @@
 			#{typeId},
 			#{emptyNum},
 			#{status},
-			NOW()
+			NOW(),
+		    #{labelIds},
+			#{labelStr}
 		)
 	</insert>
 	<insert id="insertProductImage">
@@ -266,7 +271,7 @@
 	</insert>
 
 	<update id="update">
-		UPDATE cm_baike_product SET 	
+		UPDATE cm_baike_product SET
 			name = #{name},
             shopId = #{shopId},
             productLink = #{productLink},
@@ -302,6 +307,12 @@
 					failReason = #{failReason},
 				</if>
 			</if>
+		    <if test="labelIds !=null and labelIds!=''">
+				labelIds = #{labelIds},
+			</if>
+		    <if test="labelStr !=null and labelStr !=''">
+				relatedLabels=#{labelStr},
+			</if>
 			status = #{status}
 		WHERE id = #{id}
 	</update>

+ 30 - 0
src/main/webapp/WEB-INF/views/modules/baikePage/cmBaikeProductForm.jsp

@@ -5,7 +5,11 @@
 <head>
 	<title>采美词条</title>
 	<meta name="decorator" content="default"/>
+	<link type="text/css" rel="stylesheet" href="${ctxStatic}/bootstrap-select/css/bootstrap-select.css"></link>
 	<style>
+		.dropdown bootstrap-select show-tick bs3{
+			margin-left : 20px;
+		}
 		.applicationsan{
 			user-select: none;
 			cursor: pointer;
@@ -1394,6 +1398,16 @@
 				</form:select>
 			</div>
 		</div>
+		<div class="control-group" style="margin-left: 20px">
+			<label class="control-label">关联标签库:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
+			<div>
+				<select class="selectpicker" multiple id="labelSelectBox" style="width: 240px;margin-left: 20px" name="labelIds">
+					<c:forEach items="${SearchFrequencyVo}" var="sea">
+						<option value="${sea.id}">${sea.keyword}</option>
+					</c:forEach>
+				</select>
+			</div>
+		</div>
 		<%--SEO关键词--%>
 		<div class="control-group">
 			<label class="control-label">SEO关键词:</label>
@@ -1447,6 +1461,7 @@
 <script type="text/javascript" src="${ctxStatic}/sensitiveWords/mint-filter.umd.js"></script>
 <script type="text/javascript" src="${ctxStatic}/auto-input.js"></script>
 <script type="text/javascript" src="${ctxStatic}/content-edit.js"></script>
+<script type="text/javascript" src="${ctxStatic}/bootstrap-select/js/bootstrap-select.js"></script>
 <script>
 	// 内容编辑器列表
 	var contentEditMap = new Map()
@@ -1778,6 +1793,21 @@
 		})
 	}
 
+	$(function(){
+		var cccc='${SearchFrequencyVo}';
+		console.log(cccc);
+		var labelSelectBox = $('#labelSelectBox');
+		labelSelectBox.selectpicker({
+			noneSelectedText: '请选择标签库',
+			maxOptions: 6,
+			maxOptionsText: '最多选取6个标签库'
+		});
+		// 回显操作
+		var str = '${cmBaikeProduct.labelIds}';
+		var arr = str.split(',');
+		console.log(arr)
+		labelSelectBox.selectpicker('val', arr);
+	})
 	$(function(){
 		var refren='${cmBaikeProduct.referenceList}'
 		if(''==refren|| null==refren){

Some files were not shown because too many files changed in this diff