mirror of https://github.com/jeecgboot/jeecg-boot
feat: sku to CSV
parent
e58a5f209d
commit
45fb4370e8
|
@ -0,0 +1,50 @@
|
||||||
|
package org.jeecg.modules.business.domain.job;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.modules.business.entity.Sku;
|
||||||
|
import org.jeecg.modules.business.service.ISkuService;
|
||||||
|
import org.quartz.Job;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.quartz.JobExecutionException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class SkuToCsvJob implements Job {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISkuService skuService;
|
||||||
|
|
||||||
|
@Value("${jeecg.path.skuCsvPath}")
|
||||||
|
private String FILE_PATH;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
|
log.info("SkuToCsv Job is running ...");
|
||||||
|
List<Sku> skus = new ArrayList();
|
||||||
|
Sku firstLine = new Sku();
|
||||||
|
firstLine.setId("#");
|
||||||
|
firstLine.setErpCode("erp_code");
|
||||||
|
firstLine.setImageSource("image_source");
|
||||||
|
skus.add(firstLine);
|
||||||
|
skus.addAll(skuService.listImgUrls());
|
||||||
|
List<String> csvLines = skus.stream()
|
||||||
|
.map(sku -> String.format("%s,%s,%s", sku.getId(), sku.getErpCode(), sku.getImageSource())).collect(Collectors.toList());
|
||||||
|
File csvFile = new File(FILE_PATH);
|
||||||
|
|
||||||
|
try (PrintWriter writer = new PrintWriter(csvFile)) {
|
||||||
|
csvLines.forEach(writer::println);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
log.error("Error writing to file", e);
|
||||||
|
}
|
||||||
|
log.info("SkuToCsv Job is done.");
|
||||||
|
}
|
||||||
|
}
|
|
@ -68,4 +68,6 @@ public interface SkuMapper extends BaseMapper<Sku> {
|
||||||
List<SkuOrderPage> getInventoryByInvoiceNumber(@Param("invoiceNumber") String invoiceNumber);
|
List<SkuOrderPage> getInventoryByInvoiceNumber(@Param("invoiceNumber") String invoiceNumber);
|
||||||
|
|
||||||
List<Sku> listByClientId(@Param("clientId") String clientId);
|
List<Sku> listByClientId(@Param("clientId") String clientId);
|
||||||
|
|
||||||
|
List<Sku> listImgUrls();
|
||||||
}
|
}
|
||||||
|
|
|
@ -413,4 +413,11 @@
|
||||||
JOIN product p ON s.product_id = p.id
|
JOIN product p ON s.product_id = p.id
|
||||||
WHERE client_sku.client_id = #{clientId};
|
WHERE client_sku.client_id = #{clientId};
|
||||||
</select>
|
</select>
|
||||||
|
<select id="listImgUrls" resultType="org.jeecg.modules.business.entity.Sku">
|
||||||
|
SELECT row_number() over (
|
||||||
|
ORDER BY create_time DESC
|
||||||
|
) as id, erp_code, image_source
|
||||||
|
FROM sku
|
||||||
|
WHERE image_source IS NOT NULL
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -104,4 +104,6 @@ public interface ISkuService extends IService<Sku> {
|
||||||
void updateBatchStockByIds(List<Sku> skuToUpdate);
|
void updateBatchStockByIds(List<Sku> skuToUpdate);
|
||||||
List<SkuOrderPage> getInventoryByInvoiceNumber(String invoiceNumber);
|
List<SkuOrderPage> getInventoryByInvoiceNumber(String invoiceNumber);
|
||||||
List<Sku> listByClientId(String clientId);
|
List<Sku> listByClientId(String clientId);
|
||||||
|
|
||||||
|
List<Sku> listImgUrls();
|
||||||
}
|
}
|
||||||
|
|
|
@ -480,4 +480,9 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
|
||||||
return skuMapper.listByClientId(clientId);
|
return skuMapper.listByClientId(clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Sku> listImgUrls() {
|
||||||
|
return skuMapper.listImgUrls();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -233,6 +233,8 @@ jeecg:
|
||||||
shippingInvoiceDetailDir: /wia/invoices/shippingDetail
|
shippingInvoiceDetailDir: /wia/invoices/shippingDetail
|
||||||
shippingInvoicePdfDir: /wia/invoices/pdf/shipping
|
shippingInvoicePdfDir: /wia/invoices/pdf/shipping
|
||||||
shippingInvoiceDetailPdfDir: /wia/invoices/pdf/shippingDetail
|
shippingInvoiceDetailPdfDir: /wia/invoices/pdf/shippingDetail
|
||||||
|
# sku csv file for image search
|
||||||
|
skuCsvPath: /mnt/wia/products/sku.csv
|
||||||
# CDG location
|
# CDG location
|
||||||
CGS: /wia/files/WIASourcingCGCVF_mai.pdf
|
CGS: /wia/files/WIASourcingCGCVF_mai.pdf
|
||||||
#webapp文件路径
|
#webapp文件路径
|
||||||
|
|
Loading…
Reference in New Issue