feat: labelData

pull/8040/head
Gauthier LO 2025-02-07 15:50:16 +01:00
parent 7d1bfbe03c
commit f6e06c67ec
15 changed files with 341 additions and 4 deletions

View File

@ -0,0 +1,163 @@
package org.jeecg.modules.business.controller.admin;
import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.business.entity.LabelData;
import org.jeecg.modules.business.service.ILabelDataService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description:
* @Author: jeecg-boot
* @Date: 2025-02-06
* @Version: V1.0
*/
@Api(tags="自定义分类")
@RestController
@RequestMapping("/labelData")
@Slf4j
public class LabelDataController extends JeecgController<LabelData, ILabelDataService> {
@Autowired
private ILabelDataService labelDataService;
/**
*
*
* @param labelData
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "自定义分类-分页列表查询")
@ApiOperation(value="自定义分类-分页列表查询", notes="自定义分类-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<LabelData>> queryPageList(LabelData labelData,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<LabelData> queryWrapper = QueryGenerator.initQueryWrapper(labelData, req.getParameterMap());
Page<LabelData> page = new Page<LabelData>(pageNo, pageSize);
IPage<LabelData> pageList = labelDataService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
*
*
* @param labelData
* @return
*/
@AutoLog(value = "自定义分类-添加")
@ApiOperation(value="自定义分类-添加", notes="自定义分类-添加")
@RequiresPermissions("business:label_data:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody LabelData labelData) {
labelDataService.save(labelData);
return Result.OK("添加成功!");
}
/**
*
*
* @param labelData
* @return
*/
@AutoLog(value = "自定义分类-编辑")
@ApiOperation(value="自定义分类-编辑", notes="自定义分类-编辑")
@RequiresPermissions("business:label_data:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody LabelData labelData) {
labelDataService.updateById(labelData);
return Result.OK("编辑成功!");
}
/**
* id
*
* @param id
* @return
*/
@AutoLog(value = "自定义分类-通过id删除")
@ApiOperation(value="自定义分类-通过id删除", notes="自定义分类-通过id删除")
@RequiresPermissions("business:label_data:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
labelDataService.removeById(id);
return Result.OK("删除成功!");
}
/**
*
*
* @param ids
* @return
*/
@AutoLog(value = "自定义分类-批量删除")
@ApiOperation(value="自定义分类-批量删除", notes="自定义分类-批量删除")
@RequiresPermissions("business:label_data:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.labelDataService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* id
*
* @param id
* @return
*/
//@AutoLog(value = "自定义分类-通过id查询")
@ApiOperation(value="自定义分类-通过id查询", notes="自定义分类-通过id查询")
@GetMapping(value = "/queryById")
public Result<LabelData> queryById(@RequestParam(name="id",required=true) String id) {
LabelData labelData = labelDataService.getById(id);
if(labelData==null) {
return Result.error("未找到对应数据");
}
return Result.OK(labelData);
}
/**
* excel
*
* @param request
* @param labelData
*/
@RequiresPermissions("business:label_data:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, LabelData labelData) {
return super.exportXls(request, labelData, LabelData.class, "自定义分类");
}
/**
* excel
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("business:label_data:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, LabelData.class);
}
}

View File

@ -470,7 +470,7 @@ public class SkuController {
public ModelAndView exportXls(@RequestParam Map<String, String> params) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
List<NewSkuPage> skuList = parseSkuList(params);
log.info("Request to create {} new skus in Mabang", skuList.size());
log.info("Exporting new skus to excel ...");
skuList.forEach(sku -> {
if(sku.getShippingDiscount() == null) {
sku.setShippingDiscount(BigDecimal.ONE);
@ -531,6 +531,7 @@ public class SkuController {
sku.setSupplier(map.get("supplier"));
sku.setSupplierLink(map.get("supplierLink"));
sku.setImageSource(map.get("imageSource"));
sku.setLabelData(map.get("labelData"));
return sku;
}
@PostMapping("syncSkus")

View File

@ -557,7 +557,7 @@ public class InvoiceController {
List<PlatformOrderFront> orders = platformOrderService.fetchUninvoicedOrdersByShopForClientFullSQL(shopIdList, Collections.singletonList(1), parsedColumn, parsedOrder, pageNo, pageSize,
productStatuses, shippingAvailable, purchaseAvailable);
int total = orders.get(0).getTotalCount();
int total = !order.isEmpty() ? orders.get(0).getTotalCount() : 0;
IPage<PlatformOrderFront> page = new Page<>();
page.setRecords(orders);

View File

@ -0,0 +1,15 @@
package org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
// 仓库信息,接口参数传showWarehouse才返回
public class Label {
/**自定义分类ID*/
@JSONField(name = "id")
private long id;
/**自定义分类名称**/
@JSONField(name = "name")
private String name;
}

View File

@ -60,7 +60,9 @@ public class SkuData {
/**默认供应商名称,接口参数传showProvider才返回*/
@JSONField(name="warehouse")
private Warehouse[] warehouse;
/** 自定义分类,接口参数传showLabel才返回*/
@JSONField(name="label")
private Label[] label;
@JSONField(name="warehouseName")
private String warehouseName;
/**
@ -89,6 +91,11 @@ public class SkuData {
*/
@JSONField(name="saleRemark")
private String saleRemark;
/**
* json
*/
@JSONField(name="labelData")
private Label[] labelData;
/**
* :1;2
*/

View File

@ -49,7 +49,7 @@ public class SkuListRequestBody implements RequestBody {
putNonNull(json, "showVirtualSku", showVirtualSku);
putNonNull(json, "showProvider", showProvider);
putNonNull(json, "showWarehouse", String.valueOf(showWarehouse));
putNonNull(json, "showLabel", showLabel);
putNonNull(json, "showLabel", String.valueOf(showLabel));
putNonNull(json, "showAttributes", showAttributes);
return json;
}

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.Setter;
import org.jeecg.modules.business.domain.api.mabang.RequestBody;
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.Label;
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.SkuData;
import java.math.BigDecimal;
@ -24,6 +25,7 @@ public class SkuAddRequestBody implements RequestBody {
private String declareEname;
private String warehouse;
private String remark;
private Label[] labelData;
private Integer hasBattery;
private Integer magnetic;
private Integer powder;
@ -34,6 +36,7 @@ public class SkuAddRequestBody implements RequestBody {
private Integer isGift;
private String supplier;
private String supplierLink;
private String picture;
@Override
public String api() {
@ -51,6 +54,15 @@ public class SkuAddRequestBody implements RequestBody {
putNonNull(json, "declareValue", declareValue);
putNonNull(json, "declareName", declareName);
putNonNull(json, "declareEname", declareEname);
if(labelData != null) {
JSONArray labelDataArray = new JSONArray();
for(Label label : labelData) {
JSONObject labelJson = new JSONObject();
labelJson.put("name", label.getName());
labelDataArray.add(labelJson);
}
json.put("labelData", labelDataArray.toJSONString());
}
JSONArray warehouseData = new JSONArray();
JSONObject warehouse = new JSONObject();
warehouse.put("name", this.warehouse);
@ -74,6 +86,7 @@ public class SkuAddRequestBody implements RequestBody {
supplier.put("flag", 1);
supplierData.add(supplier);
json.put("suppliersData", supplierData.toJSONString());
putNonNull(json, "picture", picture);
return json;
}
@ -87,6 +100,7 @@ public class SkuAddRequestBody implements RequestBody {
this.declareEname = data.getDeclareNameEn();
this.warehouse = data.getWarehouseName();
this.remark = data.getSaleRemark();
this.labelData = data.getLabelData();
this.hasBattery = data.getHasBattery();
this.magnetic = data.getMagnetic();
this.powder = data.getPowder();
@ -97,6 +111,7 @@ public class SkuAddRequestBody implements RequestBody {
this.isGift = data.getIsGift();
this.supplier = data.getSupplier();
this.supplierLink = data.getSupplierLink();
this.picture = data.getSalePicture();
}
private <E> void putNonNull(JSONObject json, String key, E value) {

View File

@ -0,0 +1,55 @@
package org.jeecg.modules.business.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description:
* @Author: jeecg-boot
* @Date: 2025-02-06
* @Version: V1.0
*/
@Data
@TableName("label_data")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="label_data对象", description="自定义分类")
public class LabelData implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private java.lang.String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private java.util.Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
/**自定义分类名称*/
@Excel(name = "自定义分类名称", width = 15)
@ApiModelProperty(value = "自定义分类名称")
private java.lang.String name;
}

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.business.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.business.entity.LabelData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* @Description:
* @Author: jeecg-boot
* @Date: 2025-02-06
* @Version: V1.0
*/
@Repository
public interface LabelDataMapper extends BaseMapper<LabelData> {
}

View File

@ -0,0 +1,5 @@
<?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="org.jeecg.modules.business.mapper.LabelDataMapper">
</mapper>

View File

@ -0,0 +1,14 @@
package org.jeecg.modules.business.service;
import org.jeecg.modules.business.entity.LabelData;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description:
* @Author: jeecg-boot
* @Date: 2025-02-06
* @Version: V1.0
*/
public interface ILabelDataService extends IService<LabelData> {
}

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.business.service.impl;
import org.jeecg.modules.business.entity.LabelData;
import org.jeecg.modules.business.mapper.LabelDataMapper;
import org.jeecg.modules.business.service.ILabelDataService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description:
* @Author: jeecg-boot
* @Date: 2025-02-06
* @Version: V1.0
*/
@Service
public class LabelDataServiceImpl extends ServiceImpl<LabelDataMapper, LabelData> implements ILabelDataService {
}

View File

@ -555,6 +555,13 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
skuData.setSalePrice(skuOrderPage.getSkuPrice());
skuData.setDeclareValue(skuOrderPage.getDeclaredValue());
skuData.setWarehouseName(DEFAULT_WAREHOUSE_NAME);
List<Label> labels = new ArrayList<>();
for(String labelName : skuOrderPage.getLabelData().split(",")) {
Label label = new Label();
label.setName(labelName);
labels.add(label);
}
skuData.setLabelData(labels.toArray(new Label[0]));
if(skuOrderPage.getWeight() != null)
skuData.setSaleRemark(skuOrderPage.getWeight().toString());
skuData.setHasBattery(sensitiveAttribute.getHasBattery());
@ -567,6 +574,7 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
skuData.setIsGift(skuOrderPage.getIsGift());
skuData.setSupplier(skuOrderPage.getSupplier());
skuData.setSupplierLink(skuOrderPage.getSupplierLink());
skuData.setSalePicture(skuOrderPage.getImageSource());
return skuData;
}
@ -590,6 +598,13 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
sop.setSkuPrice(skuData.getSalePrice());
if(skuData.getWarehouse() != null)
sop.setWarehouse(skuData.getWarehouse()[0].getWarehouseName());
if(skuData.getLabelData() != null) {
StringBuilder labelDataString = new StringBuilder();
for(Label labelData : skuData.getLabelData()) {
labelDataString.append(labelData.getName()).append(",");
}
sop.setLabelData(labelDataString.toString());
}
sop.setImageSource(skuData.getSalePicture());
sop.setIsGift(skuData.getIsGift());
sop.setSupplier(skuData.getSupplier());
@ -791,6 +806,7 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
for(List<String> skuPartition : skusPartition) {
SkuListRequestBody body = new SkuListRequestBody();
body.setShowWarehouse(1);
body.setShowLabel(1);
body.setStockSkuList(String.join(",", skuPartition));
SkuListRawStream rawStream = new SkuListRawStream(body);
UnpairedSkuListStream stream = new UnpairedSkuListStream(rawStream);

View File

@ -125,4 +125,8 @@ public class NewSkuPage {
@Excel(name = "仓库", width = 15)
@ApiModelProperty(value = "仓库")
private String warehouse;
@Excel(name = "自定义分类", width = 15)
@ApiModelProperty(value = "自定义分类")
private String labelData;
}

View File

@ -208,4 +208,8 @@ public class SkuOrderPage {
@Excel(name = "仓库", width = 15)
@ApiModelProperty(value = "仓库")
private String warehouse;
@Excel(name ="自定义分类", width = 15)
@ApiModelProperty(value = "自定义分类")
private String labelData;
}