feature : Making Shipping invoice in breakdown page + zip files and email

pull/6221/head
Gauthier LO 2023-08-21 12:45:04 +02:00
parent 555e697633
commit cd4ad1e5fe
13 changed files with 597 additions and 36 deletions

View File

@ -0,0 +1,177 @@
package org.jeecg.modules.business.controller.admin;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
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.common.util.oConvertUtils;
import org.jeecg.modules.business.entity.PendingTask;
import org.jeecg.modules.business.service.IPendingTaskService;
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.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
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.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
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: to know if a task in launched
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
@Api(tags="pendingTask")
@RestController
@RequestMapping("/pendingTask")
@Slf4j
public class PendingTaskController extends JeecgController<PendingTask, IPendingTaskService> {
@Autowired
private IPendingTaskService pendingTaskService;
/**
*
*
* @param pendingTask
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "to know if a task in launched-分页列表查询")
@ApiOperation(value="to know if a task in launched-分页列表查询", notes="to know if a task in launched-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<PendingTask>> queryPageList(PendingTask pendingTask,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<PendingTask> queryWrapper = QueryGenerator.initQueryWrapper(pendingTask, req.getParameterMap());
Page<PendingTask> page = new Page<PendingTask>(pageNo, pageSize);
IPage<PendingTask> pageList = pendingTaskService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
*
*
* @param pendingTask
* @return
*/
@AutoLog(value = "to know if a task in launched-添加")
@ApiOperation(value="to know if a task in launched-添加", notes="to know if a task in launched-添加")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody PendingTask pendingTask) {
pendingTaskService.save(pendingTask);
return Result.OK("添加成功!");
}
/**
*
*
* @param pendingTask
* @return
*/
@AutoLog(value = "to know if a task in launched-编辑")
@ApiOperation(value="to know if a task in launched-编辑", notes="to know if a task in launched-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody PendingTask pendingTask) {
pendingTaskService.updateById(pendingTask);
return Result.OK("编辑成功!");
}
/**
* id
*
* @param id
* @return
*/
@AutoLog(value = "to know if a task in launched-通过id删除")
@ApiOperation(value="to know if a task in launched-通过id删除", notes="to know if a task in launched-通过id删除")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
pendingTaskService.removeById(id);
return Result.OK("删除成功!");
}
/**
*
*
* @param ids
* @return
*/
@AutoLog(value = "to know if a task in launched-批量删除")
@ApiOperation(value="to know if a task in launched-批量删除", notes="to know if a task in launched-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.pendingTaskService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* id
*
* @param id
* @return
*/
//@AutoLog(value = "to know if a task in launched-通过id查询")
@ApiOperation(value="to know if a task in launched-通过id查询", notes="to know if a task in launched-通过id查询")
@GetMapping(value = "/queryById")
public Result<PendingTask> queryById(@RequestParam(name="id",required=true) String id) {
PendingTask pendingTask = pendingTaskService.getById(id);
if(pendingTask==null) {
return Result.error("未找到对应数据");
}
return Result.OK(pendingTask);
}
/**
* excel
*
* @param request
* @param pendingTask
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, PendingTask pendingTask) {
return super.exportXls(request, pendingTask, PendingTask.class, "to know if a task in launched");
}
/**
* excel
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, PendingTask.class);
}
@PostMapping(value = "/reset")
public Result<?> resetTask(@RequestBody String taskCode) {
pendingTaskService.setStatus(0, "BI");
return Result.ok("Reset successful !");
}
}

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.alibaba.fastjson.JSONObject;
import freemarker.template.Template;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
@ -21,17 +22,28 @@ import org.jeecg.modules.business.vo.*;
import org.jeecg.modules.quartz.entity.QuartzJob;
import org.jeecg.modules.quartz.service.IQuartzJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.ParseException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* Controller for request related to shipping invoice
@ -61,6 +73,22 @@ public class InvoiceController {
private IExchangeRatesService iExchangeRatesService;
@Autowired
private IQuartzJobService quartzJobService;
@Autowired
private IPendingTaskService pendingTaskService;
@Autowired
private FreeMarkerConfigurer freemarkerConfigurer;
@Autowired
private EmailService emailService;
@Value("${jeecg.path.shippingInvoiceDir}")
private String INVOICE_DIR;
@Value("${jeecg.path.shippingInvoiceDetailDir}")
private String INVOICE_DETAIL_DIR;
@Autowired
Environment env;
@GetMapping(value = "/shopsByClient")
public Result<List<Shop>> getShopsByClient(@RequestParam("clientID") String clientID) {
@ -424,40 +452,72 @@ public class InvoiceController {
/**
* Invoices all available orders with status 3 for a list of client
* @param clientCodes list of clients to invoice
* @param invoiceType invoice type (shipping or complete)
* @param shippingClientIds list of clients to invoice shipping fees
* @param completeClientIds list of clients to invoice complete fees
* @return list of invoice infos
*/
@GetMapping(value = "/breakdown/makeInvoice")
public Result<?> makeBreakdownInvoice(@RequestParam(value = "codes[]") List<String> clientCodes, @RequestParam("invoiceType") int invoiceType) {
Map<String, List<String>> clientShopIDsMap = new HashMap<>();
public Result<?> makeBreakdownInvoice(@RequestParam(value = "shipping[]", required = false) List<String> shippingClientIds,
@RequestParam(value = "complete[]", required = false) List<String> completeClientIds) throws IOException {
List<InvoiceMetaData> metaDataErrorList = new ArrayList<>();
if(pendingTaskService.getStatus("BI").equals("1")) {
return Result.error("Task is already running, please retry in a moment !");
}
List<InvoiceMetaData> invoiceList = new ArrayList<>();
for(String id: clientCodes) {
clientShopIDsMap.put(id, shopService.listIdByClient(id));
pendingTaskService.setStatus(1, "BI");
if(shippingClientIds != null) {
log.info("Making shipping invoice for clients : {}", shippingClientIds);
invoiceList.addAll(shippingInvoiceService.breakdownInvoiceClientByType(shippingClientIds, 0));
}
for(Map.Entry<String, List<String>> entry: clientShopIDsMap.entrySet()) {
Period period = shippingInvoiceService.getValidPeriod(entry.getValue());
Calendar calendar = Calendar.getInstance();
calendar.setTime(period.start());
String start = calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH)+1 < 10 ? "0" : "") + (calendar.get(Calendar.MONTH)+1) + "-" + (calendar.get(Calendar.DAY_OF_MONTH) < 10 ? "0" : "") + (calendar.get(Calendar.DAY_OF_MONTH));
calendar.setTime(period.end());
String end = calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH)+1 < 10 ? "0" : "") + (calendar.get(Calendar.MONTH)+1) + "-" + (calendar.get(Calendar.DAY_OF_MONTH)+1 < 10 ? "0" : "") + (calendar.get(Calendar.DAY_OF_MONTH)+1);
System.out.println( "[" + start + "] --- [" + end + "]");
try {
ShippingInvoiceParam param = new ShippingInvoiceParam(entry.getKey(), entry.getValue(), start, end, Collections.singletonList(3), Arrays.asList("0", "1"));
InvoiceMetaData metaData;
if(invoiceType == 0)
metaData = shippingInvoiceService.makeInvoice(param);
else
metaData = shippingInvoiceService.makeCompleteInvoicePostShipping(param, "post");
invoiceList.add(metaData);
} catch (UserException | IOException | ParseException e) {
log.error(e.getMessage());
if(completeClientIds != null) {
log.info("Making complete shipping invoice for clients : {}", completeClientIds);
invoiceList.addAll(shippingInvoiceService.breakdownInvoiceClientByType(completeClientIds, 1));
}
if(!invoiceList.isEmpty()) {
List<String> filenameList = new ArrayList<>();
for(InvoiceMetaData metaData: invoiceList){
if(metaData.getInvoiceCode().equals("error")) {
metaDataErrorList.add(metaData);
}
else {
filenameList.add(INVOICE_DIR + "//" + metaData.getFilename());
List<FactureDetail> factureDetails = shippingInvoiceService.getInvoiceDetail(metaData.getInvoiceCode());
List<SavRefundWithDetail> refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(metaData.getInvoiceCode());
shippingInvoiceService.exportToExcel(factureDetails, refunds, metaData.getInvoiceCode(), metaData.getInvoiceEntity());
filenameList.add(INVOICE_DETAIL_DIR + "//Détail_calcul_de_facture_" + metaData.getInvoiceCode() + "_(" + metaData.getInvoiceEntity() + ").xlsx");
}
}
String zipFilename = shippingInvoiceService.zipInvoices(filenameList);
String subject = "Invoices generated from Breakdown Page";
String destEmail = env.getProperty("spring.mail.username");
Properties prop = emailService.getMailSender();
Map <String, Object> templateModel = new HashMap<>();
templateModel.put("errors", metaDataErrorList);
Session session = Session.getInstance(prop, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(env.getProperty("spring.mail.username"), env.getProperty("spring.mail.password"));
}
});
try {
freemarkerConfigurer = emailService.freemarkerClassLoaderConfig();
Template freemarkerTemplate = freemarkerConfigurer.getConfiguration()
.getTemplate("breakdownInvoiceMail.ftl");
String htmlBody = FreeMarkerTemplateUtils.processTemplateIntoString(freemarkerTemplate, templateModel);
emailService.sendMessageWithAttachment(destEmail, subject, htmlBody, zipFilename,session);
log.info("Mail sent successfully");
return Result.OK("component.email.emailSent");
}
catch(Exception e) {
e.printStackTrace();
return Result.error("An error occurred while trying to send an email.");
}
System.gc();
}
return Result.ok(invoiceList);
pendingTaskService.setStatus(0, "BI");
return Result.ok();
}
/**
* Get an estimate of shipping fees for selected orders
* @param param Parameters for creating a pre-shipping invoice

View File

@ -478,7 +478,7 @@ public class ShippingInvoiceController {
return Result.OK("component.email.emailSent");
}
catch(Exception e) {
return Result.error("An error occured while trying to send an email.");
return Result.error("An error occurred while trying to send an email.");
}
}

View File

@ -0,0 +1,67 @@
package org.jeecg.modules.business.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: to know if a task in launched
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
@Data
@TableName("pending_task")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="pending_task对象", description="to know if a task in launched")
public class PendingTask 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;
/**task name*/
@Excel(name = "task name", width = 15)
@ApiModelProperty(value = "task name")
private java.lang.String name;
/**description*/
@Excel(name = "description", width = 15)
@ApiModelProperty(value = "description")
private java.lang.String description;
/**task status*/
@Excel(name = "task status", width = 15)
@ApiModelProperty(value = "task status")
private java.lang.String onGoing;
}

View File

@ -0,0 +1,21 @@
package org.jeecg.modules.business.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.business.entity.PendingTask;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* @Description: to know if a task in launched
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
@Repository
public interface PendingTaskMapper extends BaseMapper<PendingTask> {
void setStatus(@Param("status") int status, @Param("code") String taskCode);
String getStatus(@Param("code") String taskCode);
}

View File

@ -0,0 +1,14 @@
<?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.PendingTaskMapper">
<update id="setStatus">
UPDATE pending_task
SET on_going = #{status}
WHERE code = #{code};
</update>
<select id="getStatus" resultType="java.lang.String">
SELECT on_going
FROM pending_task
WHERE code = #{code};
</select>
</mapper>

View File

@ -486,7 +486,6 @@
#{warehouse}
</foreach>
AND po.shipping_time between #{startDate} AND #{endDate}
AND po.shipping_invoice_number IS NULL
AND po.erp_status = 3;
</select>
<select id="fetchUninvoicedShippedOrderIDInShopsAndOrderTime" resultType="org.jeecg.modules.business.entity.PlatformOrder">
@ -517,7 +516,6 @@
#{warehouse}
</foreach>
AND po.order_time between #{startDate} AND #{endDate}
AND po.shipping_invoice_number IS NULL
AND po.erp_status IN
<foreach
collection="erpStatuses"

View File

@ -0,0 +1,15 @@
package org.jeecg.modules.business.service;
import org.jeecg.modules.business.entity.PendingTask;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: to know if a task in launched
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
public interface IPendingTaskService extends IService<PendingTask> {
void setStatus(int status, String taskCode);
String getStatus(String taskCode);
}

View File

@ -1,7 +1,7 @@
package org.jeecg.modules.business.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.business.controller.UserException;
@ -19,6 +19,9 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@ -28,11 +31,13 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@Service
@Slf4j
public class PlatformOrderShippingInvoiceService {
@Autowired
@ -56,6 +61,8 @@ public class PlatformOrderShippingInvoiceService {
@Autowired
IPlatformOrderService platformOrderService;
@Autowired
private IShopService shopService;
@Autowired
CountryService countryService;
@Autowired
IPurchaseOrderService purchaseOrderService;
@ -235,7 +242,7 @@ public class PlatformOrderShippingInvoiceService {
purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService);
String username = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getUsername();
List<PlatformOrder> platformOrderList;
if(param.getErpStatuses().toString().equals("post")) {
if(method.equals("post")) {
//On récupère les commandes entre 2 dates d'expédition avec un status 3
platformOrderList = platformOrderMapper.fetchUninvoicedShippedOrderIDInShops(param.getStart(), param.getEnd(), param.shopIDs(), param.getWarehouses());
} else {
@ -281,7 +288,7 @@ public class PlatformOrderShippingInvoiceService {
invoice.paidAmount()
);
shippingInvoiceMapper.insert(shippingInvoiceEntity);
return new InvoiceMetaData(filename, invoice.code(), invoice.client().getInvoiceEntity());
return new InvoiceMetaData(filename, invoice.code(), invoice.client().getInvoiceEntity(), "");
}
/**
@ -431,4 +438,74 @@ public class PlatformOrderShippingInvoiceService {
System.gc();
return Files.readAllBytes(target);
}
/**
* make shipping invoice by client and type (shipping or complete)
* @param clientIds list of client codes
* @param invoiceType shipping invoice or complete invoice
* @return list of filename (invoices and details)
*/
@Transactional
public List<InvoiceMetaData> breakdownInvoiceClientByType(List<String> clientIds, int invoiceType) {
Map<String, List<String>> clientShopIDsMap = new HashMap<>();
List<InvoiceMetaData> invoiceList = new ArrayList<>();
for(String id: clientIds) {
clientShopIDsMap.put(id, shopService.listIdByClient(id));
}
for(Map.Entry<String, List<String>> entry: clientShopIDsMap.entrySet()) {
Period period = getValidPeriod(entry.getValue());
Calendar calendar = Calendar.getInstance();
calendar.setTime(period.start());
String start = calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH)+1 < 10 ? "0" : "") + (calendar.get(Calendar.MONTH)+1) + "-" + (calendar.get(Calendar.DAY_OF_MONTH) < 10 ? "0" : "") + (calendar.get(Calendar.DAY_OF_MONTH));
calendar.setTime(period.end());
String end = calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH)+1 < 10 ? "0" : "") + (calendar.get(Calendar.MONTH)+1) + "-" + (calendar.get(Calendar.DAY_OF_MONTH)+1 < 10 ? "0" : "") + (calendar.get(Calendar.DAY_OF_MONTH)+1);
log.info( "Invoicing : " + (invoiceType == 0 ? "Shipping Invoice" : "Complete Shipping Invoice") +
"\nclient : " + entry.getKey() +
"\nbetween dates : [" + start + "] --- [" + end + "]");
try {
ShippingInvoiceParam param = new ShippingInvoiceParam(entry.getKey(), entry.getValue(), start, end, Collections.singletonList(3), Arrays.asList("0", "1"));
InvoiceMetaData metaData;
if(invoiceType == 0)
metaData = makeInvoice(param);
else
metaData = makeCompleteInvoicePostShipping(param, "post");
invoiceList.add(metaData);
} catch (UserException | IOException | ParseException e) {
invoiceList.add(new InvoiceMetaData("", "error", entry.getKey(), e.getMessage()));
log.error(e.getMessage());
}
System.gc();
}
return invoiceList;
}
@Transactional
public String zipInvoices(List<String> invoiceList) throws IOException {
log.info("Zipping Invoices ...");
String username = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getUsername();
String now = new SimpleDateFormat("yyyy-MM-dd_HH-mm").format(new Date());
String zipFilename = Paths.get(INVOICE_DIR).getParent().toAbsolutePath() + "/breakdownInvoices_" + username + "_" + now +".zip";
final FileOutputStream fos = new FileOutputStream(zipFilename);
ZipOutputStream zipOut = new ZipOutputStream(fos);
for (String srcFile : invoiceList) {
File fileToZip = new File(srcFile);
FileInputStream fis = new FileInputStream(fileToZip);
ZipEntry zipEntry = new ZipEntry(fileToZip.getName());
zipOut.putNextEntry(zipEntry);
byte[] bytes = new byte[1024];
int length;
while((length = fis.read(bytes)) >= 0) {
zipOut.write(bytes, 0, length);
}
fis.close();
}
zipOut.close();
fos.close();
log.info("Zipping done ...");
return zipFilename;
}
}

View File

@ -0,0 +1,32 @@
package org.jeecg.modules.business.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.business.entity.PendingTask;
import org.jeecg.modules.business.mapper.PendingTaskMapper;
import org.jeecg.modules.business.service.IPendingTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: to know if a task in launched
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
@Service
@Slf4j
public class PendingTaskServiceImpl extends ServiceImpl<PendingTaskMapper, PendingTask> implements IPendingTaskService {
@Autowired
private PendingTaskMapper pendingTaskMapper;
@Override
public void setStatus(int status, String taskCode) {
pendingTaskMapper.setStatus(status, taskCode);
}
@Override
public String getStatus(String taskCode) {
return pendingTaskMapper.getStatus(taskCode);
}
}

View File

@ -10,4 +10,6 @@ public class InvoiceMetaData {
private final String invoiceCode;
private final String invoiceEntity;
private final String errorMsg;
}

View File

@ -0,0 +1,98 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<table align="center" cellpadding="0" cellspacing="0" width="600" bgcolor="#FFF" style="font-family:Arial,Helvetica,sans-serif;text-align:center;table-layout:fixed;font-size: 16px;border: 1px solid #0B49A6">
<tbody>
<tr>
<td width="600" height="90" bgcolor="#0B49A6" valign="top" align="center" style="padding:20px 0;table-layout:fixed">
<a href="http://app.wia-sourcing.com/user/login">
<img src="https://wia-sourcing.com/wp-content/uploads/2022/10/Fichier-24Icons.png" alt="logo" width="360" style="width:100%;max-width:360px;">
</a>
</td>
</tr>
<tr>
<td align="left">
<table width="520" align="center" style="color:#000;">
<tbody>
<tr>
<td style="padding:35px 0;">Cher collègue,</td>
</tr>
<tr>
<td style="padding:0 0 35px 0;">Vous trouverez en pièce-jointe une archive de l'ensemble des factures générées :</td>
</tr>
<tr>
<td style="padding:10px 0;"><b>Erreurs :</b>
<#if errors?size = 0>
No error
</#if>
</td>
</tr>
<#list errors as error>
<tr>
<td style="padding:10px 0;">
Error: ${error.invoiceEntity} - ${error.errorMsg}
</td>
</tr>
</#list>
<tr>
<td style="padding:35px 0 5px 0;">Merci dutiliser nos services.</td>
</tr>
<tr>
<td style="padding:5px 0;">Cordialement</td>
</tr>
<tr>
<td style="padding:5px 0 35px 0;">Léquipe WIA Sourcing.</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left" bgcolor="#0B49A6" width="600">
<table align="center" width="520">
<tbody>
<tr>
<td style="font-style: italic;padding: 20px 0;">Ce message a été envoyé automatiquement. Merci de ne pas répondre. Ce message et ainsi que toutes les pièces jointes sont confidentielles.</td>
</tr>
<tr>
<td style="padding: 0 0 20px 0;">Si vous avez reçu ce message par erreur, merci de nous avertir immédiatement et de détruire ce message.</td>
</tr>
<tr>
<td>Service client :</td>
</tr>
<tr>
<td>Pour obtenir plus dinformations concernant nos services, veuillez nous contacter à ladresse ci-dessous ou en visitant notre site web.</td>
</tr>
</tbody>
</table>
<table align="center" width="520" style="padding: 15px 0">
<tbody>
<tr>
<td width="220" style="text-align:center;border-radius:2em;padding:20px 10px 20px 0;;" bgcolor="#EF5A1A"><a href="https://wia-sourcing.com/contactez-nous" style="color:white;text-decoration:none">Nous contacter</a></td>
<td width="40" ></td>
<td width="220" style="text-align:center;border-radius:2em;padding:20px 0 20px 10px;" bgcolor="#EF5A1A"><a href="https://wia-sourcing.com/" style="color:white;text-decoration:none">Notre site web</a></td>
</tr>
</tbody>
</table>
<table align="center" width="520" style="padding: 0 0 35px 0;">
<tbody>
<tr>
<td style="color:#EF5A1A;">WIA SOURCING</td>
</tr>
<tr>
<td>© 2018/2023 par WIA Sourcing Agency.</td>
</tr>
<tr>
<td>TOUS DROITS RÉSERVÉS©</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>"

View File

@ -193,7 +193,7 @@ jeecg:
upload: C:\dev\upload
save: C:\dev\save
# email template folder
emailTemplateDir: C://Users//logau//IdeaProject//wia_app_3//wia_app//jeecg-module-system//jeecg-system-biz//src//main//resources//templates
emailTemplateDir: C://Users//logau//Documents//wia_app//jeecg-module-system//jeecg-system-biz//src//main//resources//templates
# purchase invoice template
purchaseTemplatePath: C://dev//templates//Purchase_Invoice_Template.xlsx