add generation of detail files (WIP)

pull/6221/head
Gauthier LO 2024-04-16 10:33:53 +02:00
parent c78af057e9
commit ce95c69801
13 changed files with 56 additions and 6 deletions

View File

@ -1,5 +1,5 @@
CREATE database if NOT EXISTS `wia_app_3` default character set utf8mb4 collate utf8mb4_general_ci;
USE `wia_app_3`;
CREATE database if NOT EXISTS `wia_app` default character set utf8mb4 collate utf8mb4_general_ci;
USE `wia_app`;
/*
Navicat Premium Data Transfer

View File

@ -10,7 +10,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import net.sf.saxon.functions.ScalarSystemFunction;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.OrderStatus;
import org.jeecg.modules.business.mapper.PlatformOrderMapper;
import org.jeecg.modules.business.vo.PlatformOrderQuantity;

View File

@ -29,6 +29,7 @@ import org.jeecg.modules.business.service.impl.ProviderMabangServiceImpl;
import org.jeecg.modules.business.vo.*;
import org.jeecg.modules.quartz.entity.QuartzJob;
import org.jeecg.modules.quartz.service.IQuartzJobService;
import org.jeecg.modules.system.service.ISysDepartService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -118,6 +119,8 @@ public class InvoiceController {
@Autowired
private ISysBaseAPI ISysBaseApi;
@Autowired
private ISysDepartService sysDepartService;
@Autowired
Environment env;
@Value("${jeecg.path.shippingInvoiceDir}")
@ -957,6 +960,7 @@ public class InvoiceController {
@GetMapping(value = "/checkInvoiceValidity")
public Result<?> checkInvoiceValidity(@RequestParam("invoiceNumber") String invoiceNumber) {
String companyOrgCode = sysDepartService.queryCodeByDepartName(env.getProperty("company.orgName"));
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String orgCode = sysUser.getOrgCode();
String email = sysUser.getEmail();
@ -979,7 +983,7 @@ public class InvoiceController {
client = clientService.getClientFromPurchase(invoiceID);
customerFullName = client.fullName();
String destEmail;
if(orgCode.contains("A04")) {
if(!orgCode.equals(companyOrgCode)) {
System.out.println(email + " - " + client.getEmail());
if(!client.getEmail().equals(email)) {
return Result.error(403,"Not authorized to view this page.");

View File

@ -29,4 +29,6 @@ public interface ClientMapper extends BaseMapper<Client> {
List<String> getClientsFromPurchases(@Param("purchaseIds") List<String> purchaseIds);
Client getClientBySku(@Param("skuId") String skuId);
Client getClientFromInvoice(@Param("invoiceNumber") String invoiceNumber);
}

View File

@ -64,4 +64,12 @@
JOIN client_sku cs ON c.id = cs.client_id
WHERE cs.sku_id = #{skuId};
</select>
<select id="getClientFromInvoice" resultType="org.jeecg.modules.business.entity.Client">
SELECT DISTINCT c.*
FROM client c
JOIN shop s ON s.owner_id = c.id
JOIN platform_order po ON po.shop_id = s.id
WHERE po.shipping_invoice_number = #{invoiceNumber} OR po.purchase_invoice_number = #{invoiceNumber};
</select>
</mapper>

View File

@ -56,4 +56,6 @@ public interface IClientService extends IService<Client> {
List<String> getClientsFromPurchases(List<String> purchaseIds);
Client getClientBySku(String skuId);
Client getClientFromInvoice(String invoiceNumber);
}

View File

@ -50,6 +50,8 @@ import static org.jeecg.modules.business.entity.Invoice.InvoiceType.*;
@Slf4j
public class PlatformOrderShippingInvoiceService {
@Autowired
IClientService clientService;
@Autowired
ICurrencyService currencyService;
@Autowired
@ -745,6 +747,13 @@ public class PlatformOrderShippingInvoiceService {
log.info("Generating a new invoice file ...");
if(filetype.equals("invoice"))
pathList = generateInvoiceExcel(invoiceNumber, filetype);
else if(filetype.equals("detail")){
Client client = clientService.getClientFromInvoice(invoiceNumber);
List<FactureDetail> details = getInvoiceDetail(invoiceNumber);
List<SavRefundWithDetail> refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(invoiceNumber);
exportToExcel(details, refunds, invoiceNumber, client.getInvoiceEntity(), client.getInternalCode());
pathList = getPath(INVOICE_DETAIL_DIR, invoiceNumber);
}
else {
return "ERROR";
}

View File

@ -143,6 +143,11 @@ public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> impleme
return clientMapper.getClientBySku(skuId);
}
@Override
public Client getClientFromInvoice(String invoiceNumber) {
return clientMapper.getClientFromInvoice(invoiceNumber);
}
@Override
public String getClientEntity(String id) {
return clientMapper.getClientEntity(id);

View File

@ -170,4 +170,6 @@ public interface SysDepartMapper extends BaseMapper<SysDepart> {
* @return
*/
List<SysDepartExportVo> getSysDepartList(@Param("parentId") String parentId,@Param("tenantId") Integer tenantId);
String queryCodeByDepartName(@Param("departName") String departName);
}

View File

@ -176,4 +176,9 @@
</choose>
ORDER BY depart_order DESC
</select>
<select id="queryCodeByDepartName" resultType="java.lang.String">
SELECT org_code
FROM sys_depart
WHERE depart_name = #{departName}
</select>
</mapper>

View File

@ -231,4 +231,6 @@ public interface ISysDepartService extends IService<SysDepart>{
* @param errorMessageList
*/
void importSysDepart(List<SysDepartExportVo> listSysDeparts, List<String> errorMessageList);
String queryCodeByDepartName(String departName);
}

View File

@ -1339,6 +1339,11 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
}
}
@Override
public String queryCodeByDepartName(String departName) {
return departMapper.queryCodeByDepartName(departName);
}
/**
*
*

View File

@ -160,9 +160,9 @@ spring:
slow-sql-millis: 5000
datasource:
master:
url: jdbc:mysql://127.0.0.1:3306/wia_app_3?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Europe/Paris
url: jdbc:mysql://192.168.31.16:3306/wia_app?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Europe/Paris
username: admin
password: admin
password: WIASourcing2023+
driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#multi-datasource1:
@ -223,6 +223,7 @@ jeecg:
purchaseTemplatePath: C://dev//templates//Purchase_Invoice_Template.xlsx
# where to store generated file
purchaseInvoiceDir: C://dev//invoices//purchase
purchaseInventoryDir: C://dev//invoices//inventory
# purchase invoice template
shippingTemplatePath_EU: C://dev//templates//Shipping_Invoice_Template_EU.xlsx
@ -343,3 +344,9 @@ justauth:
type: default
prefix: 'demo::'
timeout: 1h
mabang:
api:
appkey: "87a1a0c46df86eb2683e74776894dae9"
devid: "200809"
company:
orgName: "WIA"