Code optimization

pull/6221/head
Qiuyi LI 2023-08-24 14:03:32 +02:00
parent 0eb6aadbff
commit 8da45dce22
7 changed files with 240 additions and 195 deletions

View File

@ -1,28 +1,29 @@
package org.jeecg.modules.business.controller.admin; package org.jeecg.modules.business.controller.admin;
import java.util.Arrays;
import java.util.List;
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.TaskHistory;
import org.jeecg.modules.business.service.ITaskHistoryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.business.entity.TaskHistory;
import org.jeecg.modules.business.service.ITaskHistoryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
/** import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import static org.jeecg.modules.business.entity.TaskHistory.TaskStatus.CANCELLED;
/**
* @Description: task history * @Description: task history
* @Author: jeecg-boot * @Author: jeecg-boot
* @Date: 2023-08-22 * @Date: 2023-08-22
@ -163,7 +164,7 @@ public class TaskHistoryController extends JeecgController<TaskHistory, ITaskHis
public Result<?> resetTask(@RequestParam("task") String taskCode) { public Result<?> resetTask(@RequestParam("task") String taskCode) {
List<TaskHistory> allRunningTasks = taskHistoryService.getAllRunningTasksByCode(taskCode); List<TaskHistory> allRunningTasks = taskHistoryService.getAllRunningTasksByCode(taskCode);
for(TaskHistory taskHistory: allRunningTasks) { for(TaskHistory taskHistory: allRunningTasks) {
taskHistory.setOngoing(-1); taskHistory.setOngoing(CANCELLED.getCode());
taskHistoryService.updateById(taskHistory); taskHistoryService.updateById(taskHistory);
} }
return Result.ok("Reset successful !"); return Result.ok("Reset successful !");

View File

@ -41,6 +41,9 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.jeecg.modules.business.entity.Task.TaskCode.SI_G;
import static org.jeecg.modules.business.entity.TaskHistory.TaskStatus.*;
/** /**
* Controller for request related to shipping invoice * Controller for request related to shipping invoice
*/ */
@ -70,8 +73,6 @@ public class InvoiceController {
@Autowired @Autowired
private IQuartzJobService quartzJobService; private IQuartzJobService quartzJobService;
@Autowired @Autowired
private ITaskService pendingTaskService;
@Autowired
private ITaskHistoryService taskHistoryService; private ITaskHistoryService taskHistoryService;
@Autowired @Autowired
private FreeMarkerConfigurer freemarkerConfigurer; private FreeMarkerConfigurer freemarkerConfigurer;
@ -175,9 +176,8 @@ public class InvoiceController {
} }
if (pageList.getSize() > 0) { if (pageList.getSize() > 0) {
return Result.OK(pageList); return Result.OK(pageList);
} else {
return Result.error("No orders for selected client/shops");
} }
return Result.error("No orders for selected client/shops");
} }
@PostMapping(value = "/period") @PostMapping(value = "/period")
public Result<?> getValidPeriod(@RequestBody List<String> shopIDs) { public Result<?> getValidPeriod(@RequestBody List<String> shopIDs) {
@ -275,7 +275,7 @@ public class InvoiceController {
System.out.println("start : " + period.start() + "; end : " + period.end()); System.out.println("start : " + period.start() + "; end : " + period.end());
return Result.OK(period); return Result.OK(period);
} }
else return Result.error("No package in the selected period"); return Result.error("No package in the selected period");
} }
/** /**
@ -292,23 +292,22 @@ public class InvoiceController {
log.info("Requesting orders for : " + param.toString()); log.info("Requesting orders for : " + param.toString());
if (param.shopIDs() == null || param.shopIDs().isEmpty()) { if (param.shopIDs() == null || param.shopIDs().isEmpty()) {
return Result.error("Missing shop IDs"); return Result.error("Missing shop IDs");
} else {
log.info("Specified shop IDs : " + param.shopIDs());
lambdaQueryWrapper.in(PlatformOrder::getShopId, param.shopIDs());
lambdaQueryWrapper.isNull(PlatformOrder::getShippingInvoiceNumber);
if(param.getErpStatuses() != null) {
log.info("Specified erpStatuses : " + param.getErpStatuses());
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, param.getErpStatuses());
}
lambdaQueryWrapper.inSql(PlatformOrder::getId, "SELECT id FROM platform_order po WHERE po.order_time between '" + param.getStart() + "' AND '" + param.getEnd() + "'" );
// on récupère les résultats de la requete
List<PlatformOrder> orderID = platformOrderMapper.selectList(lambdaQueryWrapper);
// on récupère seulement les ID des commandes
List<String> orderIds = orderID.stream().map(PlatformOrder::getId).collect(Collectors.toList());
ShippingInvoiceOrderParam args = new ShippingInvoiceOrderParam(param.clientID(), orderIds, "pre-shipping");
// on check s'il y a des SKU sans prix
return checkSkuPrices(args);
} }
log.info("Specified shop IDs : " + param.shopIDs());
lambdaQueryWrapper.in(PlatformOrder::getShopId, param.shopIDs());
lambdaQueryWrapper.isNull(PlatformOrder::getShippingInvoiceNumber);
if(param.getErpStatuses() != null) {
log.info("Specified erpStatuses : " + param.getErpStatuses());
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, param.getErpStatuses());
}
lambdaQueryWrapper.inSql(PlatformOrder::getId, "SELECT id FROM platform_order po WHERE po.order_time between '" + param.getStart() + "' AND '" + param.getEnd() + "'" );
// on récupère les résultats de la requete
List<PlatformOrder> orderID = platformOrderMapper.selectList(lambdaQueryWrapper);
// on récupère seulement les ID des commandes
List<String> orderIds = orderID.stream().map(PlatformOrder::getId).collect(Collectors.toList());
ShippingInvoiceOrderParam args = new ShippingInvoiceOrderParam(param.clientID(), orderIds, "pre-shipping");
// on check s'il y a des SKU sans prix
return checkSkuPrices(args);
} }
/** /**
@ -325,19 +324,18 @@ public class InvoiceController {
log.info("Requesting orders for : " + param.toString()); log.info("Requesting orders for : " + param.toString());
if (param.shopIDs() == null || param.shopIDs().isEmpty()) { if (param.shopIDs() == null || param.shopIDs().isEmpty()) {
return Result.error("Missing shop IDs"); return Result.error("Missing shop IDs");
} else {
log.info("Specified shop IDs : " + param.shopIDs());
lambdaQueryWrapper.in(PlatformOrder::getShopId, param.shopIDs());
lambdaQueryWrapper.isNull(PlatformOrder::getShippingInvoiceNumber);
lambdaQueryWrapper.inSql(PlatformOrder::getId, "SELECT id FROM platform_order po WHERE po.erp_status = '3' AND po.shipping_time between '" + param.getStart() + "' AND '" + param.getEnd() + "'" );
// on récupère les résultats de la requete
List<PlatformOrder> orderID = platformOrderMapper.selectList(lambdaQueryWrapper);
// on récupère seulement les ID des commandes
List<String> orderIds = orderID.stream().map(PlatformOrder::getId).collect(Collectors.toList());
ShippingInvoiceOrderParam args = new ShippingInvoiceOrderParam(param.clientID(), orderIds, "postShipping");
// on check s'il y a des SKU sans prix
return checkSkuPrices(args);
} }
log.info("Specified shop IDs : " + param.shopIDs());
lambdaQueryWrapper.in(PlatformOrder::getShopId, param.shopIDs());
lambdaQueryWrapper.isNull(PlatformOrder::getShippingInvoiceNumber);
lambdaQueryWrapper.inSql(PlatformOrder::getId, "SELECT id FROM platform_order po WHERE po.erp_status = '3' AND po.shipping_time between '" + param.getStart() + "' AND '" + param.getEnd() + "'" );
// on récupère les résultats de la requete
List<PlatformOrder> orderID = platformOrderMapper.selectList(lambdaQueryWrapper);
// on récupère seulement les ID des commandes
List<String> orderIds = orderID.stream().map(PlatformOrder::getId).collect(Collectors.toList());
ShippingInvoiceOrderParam args = new ShippingInvoiceOrderParam(param.clientID(), orderIds, "postShipping");
// on check s'il y a des SKU sans prix
return checkSkuPrices(args);
} }
/** /**
@ -375,35 +373,34 @@ public class InvoiceController {
List<ShippingFeesEstimation> shippingFeesEstimation = shippingInvoiceService.getShippingFeesEstimation(errorMessages); List<ShippingFeesEstimation> shippingFeesEstimation = shippingInvoiceService.getShippingFeesEstimation(errorMessages);
if (shippingFeesEstimation.isEmpty()) { if (shippingFeesEstimation.isEmpty()) {
return Result.error("No data"); return Result.error("No data");
} else {
Map<String, String> clientIDCodeMap = new HashMap<>();
for(ShippingFeesEstimation estimation: shippingFeesEstimation) {
String clientId;
if(clientIDCodeMap.containsKey(estimation.getCode())){
clientId = clientIDCodeMap.get(estimation.getCode());
}
else {
clientId = clientService.getClientByInternalCode(estimation.getCode());
clientIDCodeMap.put(estimation.getCode(), clientId);
}
if (estimation.getIsCompleteInvoice().equals("1")) {
List<String> shopIds = shopService.listIdByClient(clientId);
Period period = shippingInvoiceService.getValidPeriod(shopIds);
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);
List<String> orderIds = shippingInvoiceService.getShippingOrderIdBetweenDate(shopIds, start, end, Arrays.asList("0", "1"));
ShippingInvoiceOrderParam param = new ShippingInvoiceOrderParam(clientId, orderIds, "post");
Result<?> checkSkuPrices = checkSkuPrices(param);
estimation.setErrorMessage(checkSkuPrices.getCode() == 200 ? "" : checkSkuPrices.getMessage());
}
System.gc();
}
return Result.OK(errorMessages.toString(), shippingFeesEstimation);
} }
Map<String, String> clientIDCodeMap = new HashMap<>();
for(ShippingFeesEstimation estimation: shippingFeesEstimation) {
String clientId;
if(clientIDCodeMap.containsKey(estimation.getCode())){
clientId = clientIDCodeMap.get(estimation.getCode());
}
else {
clientId = clientService.getClientByInternalCode(estimation.getCode());
clientIDCodeMap.put(estimation.getCode(), clientId);
}
if (estimation.getIsCompleteInvoice().equals("1")) {
List<String> shopIds = shopService.listIdByClient(clientId);
Period period = shippingInvoiceService.getValidPeriod(shopIds);
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);
List<String> orderIds = shippingInvoiceService.getShippingOrderIdBetweenDate(shopIds, start, end, Arrays.asList("0", "1"));
ShippingInvoiceOrderParam param = new ShippingInvoiceOrderParam(clientId, orderIds, "post");
Result<?> checkSkuPrices = checkSkuPrices(param);
estimation.setErrorMessage(checkSkuPrices.getCode() == 200 ? "" : checkSkuPrices.getMessage());
}
System.gc();
}
return Result.OK(errorMessages.toString(), shippingFeesEstimation);
} }
/** /**
@ -458,14 +455,14 @@ public class InvoiceController {
public Result<?> makeBreakdownInvoice(@RequestParam(value = "shipping[]", required = false) List<String> shippingClientIds, public Result<?> makeBreakdownInvoice(@RequestParam(value = "shipping[]", required = false) List<String> shippingClientIds,
@RequestParam(value = "complete[]", required = false) List<String> completeClientIds) throws IOException { @RequestParam(value = "complete[]", required = false) List<String> completeClientIds) throws IOException {
List<InvoiceMetaData> metaDataErrorList = new ArrayList<>(); List<InvoiceMetaData> metaDataErrorList = new ArrayList<>();
TaskHistory ongoingBITask = taskHistoryService.getLatestRunningTask("BI"); TaskHistory ongoingBITask = taskHistoryService.getLatestRunningTask(SI_G.name());
if(ongoingBITask != null) { if(ongoingBITask != null) {
return Result.error("Task is already run by " + ongoingBITask.getCreateBy() + ", please retry in a moment !"); return Result.error("Task is already run by " + ongoingBITask.getCreateBy() + ", please retry in a moment !");
} }
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
List<InvoiceMetaData> invoiceList = new ArrayList<>(); List<InvoiceMetaData> invoiceList = new ArrayList<>();
taskHistoryService.insert(new TaskHistory(sysUser.getUsername(), 1, "BI")); taskHistoryService.insert(new TaskHistory(sysUser.getUsername(), RUNNING.getCode(), SI_G.name()));
TaskHistory lastRunningTask = taskHistoryService.getLatestRunningTask("BI"); TaskHistory lastRunningTask = taskHistoryService.getLatestRunningTask(SI_G.name());
if(shippingClientIds != null) { if(shippingClientIds != null) {
log.info("Making shipping invoice for clients : {}", shippingClientIds); log.info("Making shipping invoice for clients : {}", shippingClientIds);
@ -475,59 +472,56 @@ public class InvoiceController {
log.info("Making complete shipping invoice for clients : {}", completeClientIds); log.info("Making complete shipping invoice for clients : {}", completeClientIds);
invoiceList.addAll(shippingInvoiceService.breakdownInvoiceClientByType(completeClientIds, 1)); invoiceList.addAll(shippingInvoiceService.breakdownInvoiceClientByType(completeClientIds, 1));
} }
if(!invoiceList.isEmpty()) { if (invoiceList.isEmpty()) {
List<String> filenameList = new ArrayList<>(); lastRunningTask.setOngoing(SUCCESS.getCode());
log.info("Generating detail files ...0/{}", invoiceList.size()); taskHistoryService.updateById(lastRunningTask);
int cpt = 1; return Result.ok("Nothing invoiced");
for(InvoiceMetaData metaData: invoiceList){ }
if(metaData.getInvoiceCode().equals("error")) { List<String> filenameList = new ArrayList<>();
metaDataErrorList.add(metaData); log.info("Generating detail files ...0/{}", invoiceList.size());
} int cpt = 1;
else { for (InvoiceMetaData metaData : invoiceList) {
filenameList.add(INVOICE_DIR + "//" + metaData.getFilename()); if (metaData.getInvoiceCode().equals("error")) {
List<FactureDetail> factureDetails = shippingInvoiceService.getInvoiceDetail(metaData.getInvoiceCode()); metaDataErrorList.add(metaData);
List<SavRefundWithDetail> refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(metaData.getInvoiceCode()); } else {
shippingInvoiceService.exportToExcel(factureDetails, refunds, metaData.getInvoiceCode(), metaData.getInvoiceEntity()); filenameList.add(INVOICE_DIR + "//" + metaData.getFilename());
filenameList.add(INVOICE_DETAIL_DIR + "//Détail_calcul_de_facture_" + metaData.getInvoiceCode() + "_(" + metaData.getInvoiceEntity() + ").xlsx"); List<FactureDetail> factureDetails = shippingInvoiceService.getInvoiceDetail(metaData.getInvoiceCode());
} List<SavRefundWithDetail> refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(metaData.getInvoiceCode());
log.info("Generating detail files ...{}/{}", cpt++, invoiceList.size()); 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"; log.info("Generating detail files ...{}/{}", cpt++, invoiceList.size());
String destEmail = sysUser.getEmail(); }
Properties prop = emailService.getMailSender(); String zipFilename = shippingInvoiceService.zipInvoices(filenameList);
Map <String, Object> templateModel = new HashMap<>(); String subject = "Invoices generated from Breakdown Page";
templateModel.put("errors", metaDataErrorList); String destEmail = sysUser.getEmail();
Properties prop = emailService.getMailSender();
Session session = Session.getInstance(prop, new Authenticator() { Map<String, Object> templateModel = new HashMap<>();
@Override templateModel.put("errors", metaDataErrorList);
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(env.getProperty("spring.mail.username"), env.getProperty("spring.mail.password")); Session session = Session.getInstance(prop, new Authenticator() {
} @Override
}); protected PasswordAuthentication getPasswordAuthentication() {
try { return new PasswordAuthentication(env.getProperty("spring.mail.username"), env.getProperty("spring.mail.password"));
freemarkerConfigurer = emailService.freemarkerClassLoaderConfig(); }
Template freemarkerTemplate = freemarkerConfigurer.getConfiguration() });
.getTemplate("breakdownInvoiceMail.ftl"); try {
String htmlBody = FreeMarkerTemplateUtils.processTemplateIntoString(freemarkerTemplate, templateModel); freemarkerConfigurer = emailService.freemarkerClassLoaderConfig();
emailService.sendMessageWithAttachment(destEmail, subject, htmlBody, zipFilename,session); Template freemarkerTemplate = freemarkerConfigurer.getConfiguration()
log.info("Mail sent successfully"); .getTemplate("breakdownInvoiceMail.ftl");
String htmlBody = FreeMarkerTemplateUtils.processTemplateIntoString(freemarkerTemplate, templateModel);
lastRunningTask.setOngoing(0); emailService.sendMessageWithAttachment(destEmail, subject, htmlBody, zipFilename, session);
taskHistoryService.updateById(lastRunningTask); log.info("Mail sent successfully");
return Result.OK("component.email.emailSent");
} lastRunningTask.setOngoing(SUCCESS.getCode());
catch(Exception e) { taskHistoryService.updateById(lastRunningTask);
e.printStackTrace(); return Result.OK("component.email.emailSent");
} catch (Exception e) {
lastRunningTask.setOngoing(-1); e.printStackTrace();
taskHistoryService.updateById(lastRunningTask); lastRunningTask.setOngoing(CANCELLED.getCode());
return Result.error("An error occurred while trying to send an email."); taskHistoryService.updateById(lastRunningTask);
} return Result.error("An error occurred while trying to send an email.");
} }
lastRunningTask.setOngoing(0);
taskHistoryService.updateById(lastRunningTask);
return Result.ok("Nothing invoiced");
} }
/** /**
@ -553,31 +547,31 @@ public class InvoiceController {
String customerFullName; String customerFullName;
invoiceNumber = iShippingInvoiceService.getShippingInvoiceNumber(invoiceID); invoiceNumber = iShippingInvoiceService.getShippingInvoiceNumber(invoiceID);
// if invoice exists // if invoice exists
if(invoiceNumber != null) { if (invoiceNumber == null) {
// if user is a customer, we check if he's the owner of the shops return Result.error("Error 404 page not found.");
Client client = iShippingInvoiceService.getShopOwnerFromInvoiceNumber(invoiceNumber); }
customerFullName = client.fullName(); // if user is a customer, we check if he's the owner of the shops
String destEmail; Client client = iShippingInvoiceService.getShopOwnerFromInvoiceNumber(invoiceNumber);
if(orgCode.contains("A04")) { customerFullName = client.fullName();
if(!client.getEmail().equals(email)) { String destEmail;
return Result.error("Not authorized to view this page."); if(orgCode.contains("A04")) {
} if(!client.getEmail().equals(email)) {
else { return Result.error("Not authorized to view this page.");
destEmail = client.getEmail();
}
} }
else { else {
destEmail = email; destEmail = client.getEmail();
} }
JSONObject json = new JSONObject();
json.put("name", customerFullName);
json.put("email", destEmail);
json.put("invoiceEntity", client.getInvoiceEntity());
json.put("invoiceNumber", invoiceNumber);
json.put("currency", client.getCurrency());
return Result.OK(json);
} }
return Result.error("Error 404 page not found."); else {
destEmail = email;
}
JSONObject json = new JSONObject();
json.put("name", customerFullName);
json.put("email", destEmail);
json.put("invoiceEntity", client.getInvoiceEntity());
json.put("invoiceNumber", invoiceNumber);
json.put("currency", client.getCurrency());
return Result.OK(json);
} }
/** /**

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.business.entity; package org.jeecg.modules.business.entity;
import java.io.Serializable; import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -14,45 +15,65 @@ import io.swagger.annotations.ApiModelProperty;
/** /**
* @Description: tasks * @Description: tasks
* @Author: jeecg-boot * @Author: jeecg-boot
* @Date: 2023-08-22 * @Date: 2023-08-22
* @Version: V1.0 * @Version: V1.0
*/ */
@Data @Data
@TableName("task") @TableName("task")
@ApiModel(value="task对象", description="tasks") @ApiModel(value = "task对象", description = "tasks")
public class Task implements Serializable { public class Task implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**主键*/ /**
@TableId(type = IdType.ASSIGN_ID) *
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键") @ApiModelProperty(value = "主键")
private java.lang.String id; private java.lang.String id;
/**创建人*/ /**
*
*/
@ApiModelProperty(value = "创建人") @ApiModelProperty(value = "创建人")
private java.lang.String createBy; private java.lang.String createBy;
/**创建日期*/ /**
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") *
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期") @ApiModelProperty(value = "创建日期")
private java.util.Date createTime; private java.util.Date createTime;
/**更新人*/ /**
*
*/
@ApiModelProperty(value = "更新人") @ApiModelProperty(value = "更新人")
private java.lang.String updateBy; private java.lang.String updateBy;
/**更新日期*/ /**
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") *
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期") @ApiModelProperty(value = "更新日期")
private java.util.Date updateTime; private java.util.Date updateTime;
/**taskCode*/ /**
@Excel(name = "taskCode", width = 15) * taskCode
*/
@Excel(name = "taskCode", width = 15)
@ApiModelProperty(value = "taskCode") @ApiModelProperty(value = "taskCode")
private java.lang.String code; private java.lang.String code;
/**taskName*/ /**
@Excel(name = "taskName", width = 15) * taskName
*/
@Excel(name = "taskName", width = 15)
@ApiModelProperty(value = "taskName") @ApiModelProperty(value = "taskName")
private java.lang.String name; private java.lang.String name;
/**description*/ /**
@Excel(name = "description", width = 15) * description
*/
@Excel(name = "description", width = 15)
@ApiModelProperty(value = "description") @ApiModelProperty(value = "description")
private java.lang.String description; private java.lang.String description;
public enum TaskCode {
SI_G
}
} }

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.business.entity; package org.jeecg.modules.business.entity;
import java.io.Serializable; import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -14,41 +15,55 @@ import io.swagger.annotations.ApiModelProperty;
/** /**
* @Description: task history * @Description: task history
* @Author: jeecg-boot * @Author: jeecg-boot
* @Date: 2023-08-22 * @Date: 2023-08-22
* @Version: V1.0 * @Version: V1.0
*/ */
@Data @Data
@TableName("task_history") @TableName("task_history")
@ApiModel(value="task_history对象", description="task history") @ApiModel(value = "task_history对象", description = "task history")
public class TaskHistory implements Serializable { public class TaskHistory implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**主键*/ /**
@TableId(type = IdType.ASSIGN_ID) *
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键") @ApiModelProperty(value = "主键")
private java.lang.String id; private java.lang.String id;
/**创建人*/ /**
*
*/
@ApiModelProperty(value = "创建人") @ApiModelProperty(value = "创建人")
private java.lang.String createBy; private java.lang.String createBy;
/**创建日期*/ /**
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") *
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期") @ApiModelProperty(value = "创建日期")
private java.util.Date createTime; private java.util.Date createTime;
/**更新人*/ /**
*
*/
@ApiModelProperty(value = "更新人") @ApiModelProperty(value = "更新人")
private java.lang.String updateBy; private java.lang.String updateBy;
/**更新日期*/ /**
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") *
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期") @ApiModelProperty(value = "更新日期")
private java.util.Date updateTime; private java.util.Date updateTime;
/**ongoing*/ /**
@Excel(name = "ongoing", width = 15) * ongoing
*/
@Excel(name = "ongoing", width = 15)
@ApiModelProperty(value = "ongoing") @ApiModelProperty(value = "ongoing")
private java.lang.Integer ongoing; private java.lang.Integer ongoing;
/**task code*/ /**
@Excel(name = "task code", width = 15) * task code
*/
@Excel(name = "task code", width = 15)
@ApiModelProperty(value = "task id") @ApiModelProperty(value = "task id")
private java.lang.String taskCode; private java.lang.String taskCode;
@ -60,4 +75,20 @@ public class TaskHistory implements Serializable {
public TaskHistory() { public TaskHistory() {
} }
public enum TaskStatus {
RUNNING(1),
SUCCESS(0),
CANCELLED(-1);
private final int code;
TaskStatus(int code) {
this.code = code;
}
public int getCode() {
return code;
}
}
} }

View File

@ -289,7 +289,8 @@
purchase_fee = 0.0, purchase_fee = 0.0,
erp_status = erp_status =
CASE erp_status CASE erp_status
WHEN 4 THEN 3 WHEN '4' THEN '3'
ELSE erp_status
END END
WHERE platform_order_id IN (SELECT id FROM platform_order WHERE shipping_invoice_number = #{invoiceNumber}); WHERE platform_order_id IN (SELECT id FROM platform_order WHERE shipping_invoice_number = #{invoiceNumber});
</update> </update>
@ -302,7 +303,8 @@
purchase_fee = 0.0, purchase_fee = 0.0,
erp_status = erp_status =
CASE erp_status CASE erp_status
WHEN 4 THEN 3 WHEN '4' THEN '3'
ELSE erp_status
END END
WHERE platform_order_id IN WHERE platform_order_id IN
(SELECT id FROM platform_order (SELECT id FROM platform_order

View File

@ -598,9 +598,7 @@
erp_status = erp_status =
CASE erp_status CASE erp_status
WHEN '4' THEN '3' WHEN '4' THEN '3'
WHEN '3' THEN '3' ELSE erp_status
WHEN '1' THEN '1'
WHEN '2' THEN '2'
END END
WHERE shipping_invoice_number = #{invoiceNumber}; WHERE shipping_invoice_number = #{invoiceNumber};
</update> </update>
@ -614,9 +612,7 @@
erp_status = erp_status =
CASE erp_status CASE erp_status
WHEN '4' THEN '3' WHEN '4' THEN '3'
WHEN '3' THEN '3' ELSE erp_status
WHEN '1' THEN '1'
WHEN '2' THEN '2'
END END
WHERE shipping_invoice_number IN WHERE shipping_invoice_number IN
<foreach collection="invoiceNumbers" separator="," open="(" close=")" index="index" item="invoiceNumber"> <foreach collection="invoiceNumbers" separator="," open="(" close=")" index="index" item="invoiceNumber">

View File

@ -15,7 +15,7 @@ public interface ITaskHistoryService extends IService<TaskHistory> {
TaskHistory getLatestRunningTask(String taskCode); TaskHistory getLatestRunningTask(String taskCode);
List<TaskHistory> getAllRunningTasksByCode(String bi); List<TaskHistory> getAllRunningTasksByCode(String code);
void insert(TaskHistory taskHistory); void insert(TaskHistory taskHistory);
} }