|
@@ -0,0 +1,197 @@
|
|
|
+package com.malk.diwei.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.malk.diwei.entity.*;
|
|
|
+import com.malk.diwei.mapper.*;
|
|
|
+import com.malk.diwei.service.GoodsService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.malk.server.aliwork.YDConf;
|
|
|
+import com.malk.server.aliwork.YDParam;
|
|
|
+import com.malk.server.common.McR;
|
|
|
+import com.malk.service.aliwork.YDClient;
|
|
|
+import com.malk.utils.UtilMap;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author WZY
|
|
|
+ * @since 2025-03-12
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
|
|
|
+ @Autowired
|
|
|
+ private GoodsMapper goodsMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GoodsCategoryMapper goodsCategoryMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BrandMapper brandMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GoodsUnitMapper goodsUnitMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UnitMapper unitMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GoodsColorMapper goodsColorMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ColorMapper colorMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GoodsSizeMapper goodsSizeMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SizeMapper sizeMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private YDClient ydClient;
|
|
|
+
|
|
|
+ public McR syncGoods() {
|
|
|
+ //查询昨天修改的物料
|
|
|
+ LambdaQueryWrapper<Goods> goodsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+// goodsLambdaQueryWrapper.ge(Goods::getGoodsUpdateDatetime,DateUtil.yesterday());
|
|
|
+ List<Goods> goods = goodsMapper.selectList(goodsLambdaQueryWrapper);
|
|
|
+
|
|
|
+ for (Goods good : goods) {
|
|
|
+ Map formData = new HashMap();
|
|
|
+ formData.put("numberField_m85b219y",good.getGoodsID());//物料id
|
|
|
+ formData.put("textField_m82g94gl",good.getGoodsCode());//货号
|
|
|
+ formData.put("textField_m82g94gm",good.getGoodsName());//货品名称
|
|
|
+ formData.put("textField_m82g94gn",good.getGoodsIngredients());//成分
|
|
|
+ formData.put("textField_m82g94gt",good.getGoodsShortCode());//助记码
|
|
|
+ formData.put("textField_m82g94gu",good.getGoodsAliasName());//货品别名
|
|
|
+ formData.put("textField_m82g94gv",good.getGoodsSpecs());//货品规格
|
|
|
+ formData.put("textField_m82g94h2",good.getGoodsShortName());//货品简称
|
|
|
+
|
|
|
+ //货品类别
|
|
|
+ LambdaQueryWrapper<GoodsCategory> goodsCategoryLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ goodsCategoryLambdaQueryWrapper.eq(GoodsCategory::getGoodsCategoryID,good.getGoodsCategoryID());
|
|
|
+ GoodsCategory goodsCategory = goodsCategoryMapper.selectOne(goodsCategoryLambdaQueryWrapper);
|
|
|
+ if (Objects.nonNull(goodsCategory)){
|
|
|
+ formData.put("textField_m82g94h3",goodsCategory.getGoodsCategoryName());
|
|
|
+ }
|
|
|
+
|
|
|
+ //货品属性
|
|
|
+ if (Objects.nonNull(good.getGoodsProperty())){
|
|
|
+ switch (good.getGoodsProperty()){
|
|
|
+ case 0 : formData.put("textField_m82g94h4","不限");break;
|
|
|
+ case 1 : formData.put("textField_m82g94h4","成品");break;
|
|
|
+ case 2 : formData.put("textField_m82g94h4","半成品");break;
|
|
|
+ case 3 : formData.put("textField_m82g94h4","原料");break;
|
|
|
+ case 4 : formData.put("textField_m82g94h4","辅料");break;
|
|
|
+ case 5 : formData.put("textField_m82g94h4","办公用品");break;
|
|
|
+ case 6 : formData.put("textField_m82g94h4","低值易耗品");break;
|
|
|
+ case 7 : formData.put("textField_m82g94h4","劳务/服务");break;
|
|
|
+ default : break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //品牌名称
|
|
|
+ LambdaQueryWrapper<Brand> brandLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ brandLambdaQueryWrapper.eq(Brand::getBrandId,good.getBrandId());
|
|
|
+ Brand brand = brandMapper.selectOne(brandLambdaQueryWrapper);
|
|
|
+ if (Objects.nonNull(brand)){
|
|
|
+ formData.put("textField_m82g94h9",brand.getBrandName());
|
|
|
+ }
|
|
|
+
|
|
|
+ formData.put("textField_m82g94ho",good.getGoodsNeedleType());//针型
|
|
|
+ formData.put("textField_m82g94hp",good.getGoodsMachineType());//机型
|
|
|
+ formData.put("numberField_m85b21a3",good.getGoodsGWeight());//克重
|
|
|
+
|
|
|
+ //启用/停用
|
|
|
+ if (Objects.nonNull(good.getGoodsDisable())){
|
|
|
+ switch (good.getGoodsDisable()){
|
|
|
+ case 0 : formData.put("selectField_m82g94hh","启用");break;
|
|
|
+ case 1 : formData.put("selectField_m82g94hh","停用");break;
|
|
|
+ default : break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //库存预警
|
|
|
+ if (Objects.nonNull(good.getGoodsCheckStatus())){
|
|
|
+ switch (good.getGoodsCheckStatus()){
|
|
|
+ case 0 : formData.put("selectField_m82g94hv","关闭");break;
|
|
|
+ case 1 : formData.put("selectField_m82g94hv","开启");break;
|
|
|
+ default : break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ formData.put("textareaField_m85b21a2",good.getGoodsDescription());//备注
|
|
|
+
|
|
|
+ //单位名称
|
|
|
+ LambdaQueryWrapper<GoodsUnit> goodsUnitLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ goodsUnitLambdaQueryWrapper.eq(GoodsUnit::getGoodsID,good.getGoodsID());
|
|
|
+ GoodsUnit goodsUnit = goodsUnitMapper.selectOne(goodsUnitLambdaQueryWrapper);
|
|
|
+ if (Objects.nonNull(goodsUnit)){
|
|
|
+ LambdaQueryWrapper<Unit> unitLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ unitLambdaQueryWrapper.eq(Unit::getUnitID,goodsUnit.getUnitID());
|
|
|
+ Unit unit = unitMapper.selectOne(unitLambdaQueryWrapper);
|
|
|
+ if (Objects.nonNull(unit)){
|
|
|
+ formData.put("textField_m85b218v",unit.getUnitName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //颜色
|
|
|
+ LambdaQueryWrapper<GoodsColor> goodsColorLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ goodsColorLambdaQueryWrapper.eq(GoodsColor::getGoodsID,good.getGoodsID());
|
|
|
+ List<GoodsColor> goodsColorList = goodsColorMapper.selectList(goodsColorLambdaQueryWrapper);
|
|
|
+ if(Objects.nonNull(goodsColorList) && !goodsColorList.isEmpty()){
|
|
|
+ List<Map> colorList = new ArrayList<>();
|
|
|
+ for (GoodsColor goodsColor : goodsColorList) {
|
|
|
+ Map colorMap = new HashMap();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<Color> colorLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ colorLambdaQueryWrapper.eq(Color::getColorID,goodsColor.getColorID());
|
|
|
+ Color color = colorMapper.selectOne(colorLambdaQueryWrapper);
|
|
|
+ if (Objects.nonNull(color)){
|
|
|
+ colorMap.put("textField_m85b219g",color.getColorName());
|
|
|
+ }
|
|
|
+ colorList.add(colorMap);
|
|
|
+ }
|
|
|
+ formData.put("tableField_m85b219h",colorList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //尺码
|
|
|
+ LambdaQueryWrapper<GoodsSize> goodsSizeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ goodsSizeLambdaQueryWrapper.eq(GoodsSize::getGoodsID,good.getGoodsID());
|
|
|
+ List<GoodsSize> goodsSizeList = goodsSizeMapper.selectList(goodsSizeLambdaQueryWrapper);
|
|
|
+ if(Objects.nonNull(goodsSizeList) && !goodsSizeList.isEmpty()){
|
|
|
+ List<Map> sizeList = new ArrayList<>();
|
|
|
+ for (GoodsSize goodsSize : goodsSizeList) {
|
|
|
+ Map sizeMap = new HashMap();
|
|
|
+ LambdaQueryWrapper<Size> sizeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ sizeLambdaQueryWrapper.eq(Size::getSizeID,goodsSize.getSizeID());
|
|
|
+ Size size = sizeMapper.selectOne(sizeLambdaQueryWrapper);
|
|
|
+ if (Objects.nonNull(size)){
|
|
|
+ sizeMap.put("textField_m85b219m",size.getSizeName());
|
|
|
+ }
|
|
|
+ sizeMap.put("textField_m85b219o",goodsSize.getGoodsSizeDes());//备注
|
|
|
+ sizeList.add(sizeMap);
|
|
|
+ }
|
|
|
+ formData.put("tableField_m85b219n",sizeList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //精准匹配
|
|
|
+ List<Map> searchCondition = new ArrayList<>();
|
|
|
+ searchCondition.add(UtilMap.map("key, value, type, operator, componentName","textField_m82g94gl",good.getGoodsCode(),"TEXT","eq","TextField"));
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formUuid("FORM-06568CCD028F45278F6D571FDD5B91A5X2FX")
|
|
|
+ .searchCondition(JSONObject.toJSONString(searchCondition))
|
|
|
+ .formDataJson(JSONObject.toJSONString(formData))
|
|
|
+ .build(), YDConf.FORM_OPERATION.upsert);
|
|
|
+ }
|
|
|
+
|
|
|
+ return McR.success();
|
|
|
+ }
|
|
|
+}
|