定时统计功能修改

dev
徐杰盟 2024-03-05 13:36:31 +08:00
parent 89e26a419c
commit 768070aead
6 changed files with 59 additions and 18 deletions

View File

@ -8,7 +8,6 @@ import com.google.zxing.qrcode.QRCodeWriter;
import com.jfinal.kit.Base64Kit; import com.jfinal.kit.Base64Kit;
import com.jfinal.log.Log; import com.jfinal.log.Log;
import net.coobird.thumbnailator.Thumbnails; import net.coobird.thumbnailator.Thumbnails;
import sun.misc.BASE64Decoder;
import java.io.*; import java.io.*;
import java.util.Base64; import java.util.Base64;
@ -40,11 +39,12 @@ public class ImageUtil {
if (imgStr == null) // 图像数据为空 if (imgStr == null) // 图像数据为空
return false; return false;
BASE64Decoder decoder = new BASE64Decoder(); // BASE64Decoder decoder = new BASE64Decoder();
OutputStream out = null; OutputStream out = null;
try { try {
// Base64解码 // Base64解码
byte[] bytes = decoder.decodeBuffer(imgStr); // byte[] bytes = decoder.decodeBuffer(imgStr);
byte[] bytes = Base64.getDecoder().decode(imgStr);
for (int i = 0; i < bytes.length; ++i) { for (int i = 0; i < bytes.length; ++i) {
if (bytes[i] < 0) {// 调整异常数据 if (bytes[i] < 0) {// 调整异常数据
bytes[i] += 256; bytes[i] += 256;

View File

@ -61,12 +61,23 @@ public class OrderEndService extends BaseService {
} }
public List<OrderEnd> getOrderEndByTm(String tm) { public List<OrderEnd> getOrderEndByTm(String tm,String customerId) {
List<Object> paraList = new ArrayList<>();
String sql = "SELECT * FROM ORDER_END \n" + String sql = "SELECT * FROM ORDER_END \n" +
"WHERE DATE = ? \n"; "WHERE 1 = 1 \n";
return OrderEnd.dao.find(sql,tm); if (!StringUtils.isEmpty(tm)){
sql += " AND DATE = ? \n";
paraList.add(tm);
}
if (!StringUtils.isEmpty(customerId)){
sql += " AND CUSTOMER_ID = ? \n";
paraList.add(customerId);
}
return OrderEnd.dao.find(sql,paraList.toArray());
} }
public void initialize(){ public void initialize(){
@ -82,22 +93,28 @@ public class OrderEndService extends BaseService {
public void syncOrderTemp(String tm){ public void syncOrderTemp(String tm){
try { try {
processing(tm); queryList(tm,null);
}catch (Exception e){ }catch (Exception e){
log.error("同步数据异常 %s %s", e.getMessage(),e); log.error("同步数据异常 %s %s", e.getMessage(),e);
} }
} }
public void processing(String tm){
public void queryList(String tm,String customerId) {
// 获取历史数据 // 获取历史数据
List<Record> tempList = OrderTempService.me.getOrderTempGroupBy(tm); List<Record> tempList = OrderTempService.me.getOrderTempGroupBy(tm,customerId);
if (CollectionUtils.isEmpty(tempList)){ if (CollectionUtils.isEmpty(tempList)) {
log.info("数据结果为空"); log.info("数据结果为空");
return; throw new IllegalArgumentException("数据结果为空");
} }
processing(tm,customerId,tempList);
}
public void processing(String tm,String customerId,List<Record> tempList){
List<OrderEnd> orderEnds = tempList.stream() List<OrderEnd> orderEnds = tempList.stream()
.map(data -> { .map(data -> {
@ -111,8 +128,13 @@ public class OrderEndService extends BaseService {
List<String> deletes = new ArrayList<>(); List<String> deletes = new ArrayList<>();
// 如果当前时间类型已存在 就更新 // 如果当前时间类型已存在 就更新
if (!StringUtils.isEmpty(tm)){ List<OrderEnd> lists = null;
List<OrderEnd> lists = getOrderEndByTm(tm); if (StringUtils.isEmpty(tm) || StringUtils.isEmpty(customerId)){
lists = getOrderEndByTm(tm,customerId);
}
if (CollectionUtils.isNotEmpty(lists)){
if (CollectionUtils.isNotEmpty(lists)){ if (CollectionUtils.isNotEmpty(lists)){
Map<String, List<OrderEnd>> map = lists.stream() Map<String, List<OrderEnd>> map = lists.stream()

View File

@ -454,17 +454,20 @@ public class OrderTempService extends BaseService {
* @tm %Y-%M-%D * @tm %Y-%M-%D
* @return * @return
*/ */
public List<Record> getOrderTempGroupBy(String tm) { public List<Record> getOrderTempGroupBy(String tm,String customerId) {
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
String findSql = ""; String findSql = "";
if (customerId != null) {
findSql = " AND CUSTOMER_ID = ? \n";
paraList.add(customerId);
}
if (tm != null) { if (tm != null) {
findSql = " AND CREATE_TIME BETWEEN ? AND ? \n"; findSql = " AND CREATE_TIME BETWEEN ? AND ? \n";
paraList.add(tm + STM_SUFFIX); paraList.add(tm + STM_SUFFIX);
paraList.add(tm + ETM_SUFFIX); paraList.add(tm + ETM_SUFFIX);
} } else{
else{
findSql = " AND CREATE_TIME < ? \n"; findSql = " AND CREATE_TIME < ? \n";
paraList.add(LocalDate.now() + STM_SUFFIX); paraList.add(LocalDate.now() + STM_SUFFIX);
} }

View File

@ -7,11 +7,14 @@ import com.cowr.common.view.ExcelRender;
import com.cowr.common.view.PageParam; import com.cowr.common.view.PageParam;
import com.cowr.common.view.Result; import com.cowr.common.view.Result;
import com.cowr.model.Sysuser; import com.cowr.model.Sysuser;
import com.cowr.service.ssjygl.main.AuthInterceptor;
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService; import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
import com.cowr.ssjygl.order.OrderCancelValidator; import com.cowr.ssjygl.order.OrderCancelValidator;
import com.cowr.ssjygl.order.orderend.OrderEndService;
import com.cowr.ssjygl.order.ordertemp.OrderTempPKValidator; import com.cowr.ssjygl.order.ordertemp.OrderTempPKValidator;
import com.cowr.ssjygl.order.ordertemp.OrderTempService; import com.cowr.ssjygl.order.ordertemp.OrderTempService;
import com.jfinal.aop.Before; import com.jfinal.aop.Before;
import com.jfinal.aop.Clear;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import static com.cowr.common.utils.DateTimeUtil.TM_TIME; import static com.cowr.common.utils.DateTimeUtil.TM_TIME;
@ -105,4 +108,17 @@ public class OrderTempController extends BaseController {
renderJson(OrderTempSyncService.me.cancel(sn, invalid_memo, tokenuser, password)); renderJson(OrderTempSyncService.me.cancel(sn, invalid_memo, tokenuser, password));
} }
/**
*
*/
@Clear(AuthInterceptor.class)
public void updateOrderEnd() {
String tm = get("tm");
String customerId = get("customerId");
OrderEndService.me.queryList(tm, customerId); // 通过接口更新
renderJson();
}
} }

View File

@ -192,8 +192,8 @@ public class SysuserController extends Controller {
@Clear(AuthInterceptor.class) @Clear(AuthInterceptor.class)
public void login() { public void login() {
if (!validateCaptcha("captcha")) { if (!validateCaptcha("captcha")) {
renderJson(Result.failed("验证码输入错误")); // renderJson(Result.failed("验证码输入错误"));
return; // return;
} }
String name = get("name", "").trim(); String name = get("name", "").trim();