|
@@ -307,7 +307,6 @@ public class OrderDinnerServiceImpl implements OrderDinnerService {
|
|
* 判断餐品是否有效
|
|
* 判断餐品是否有效
|
|
* 然后根据当前登录用户将购物车中的餐品提交到餐品详情中
|
|
* 然后根据当前登录用户将购物车中的餐品提交到餐品详情中
|
|
*
|
|
*
|
|
- * @param openId
|
|
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Transactional
|
|
@Transactional
|
|
@@ -631,7 +630,6 @@ public class OrderDinnerServiceImpl implements OrderDinnerService {
|
|
/**
|
|
/**
|
|
* 保存订单详情
|
|
* 保存订单详情
|
|
*
|
|
*
|
|
- * @param consId
|
|
|
|
* @param orderId
|
|
* @param orderId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -687,7 +685,8 @@ public class OrderDinnerServiceImpl implements OrderDinnerService {
|
|
int weekDate = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
|
int weekDate = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
|
//首先获取周期,然后获取周期下对应的购物车中的数据,如果周期下没有数据,就不需要展示这个周期
|
|
//首先获取周期,然后获取周期下对应的购物车中的数据,如果周期下没有数据,就不需要展示这个周期
|
|
List<WeekMealCarDto> weekDtoList = new ArrayList<WeekMealCarDto>();
|
|
List<WeekMealCarDto> weekDtoList = new ArrayList<WeekMealCarDto>();
|
|
- List<WeekDate> weekList = DateUtils.getWeek();
|
|
|
|
|
|
+// List<WeekDate> weekList = DateUtils.getWeek();//--------------------------20220526-----------------------------------
|
|
|
|
+ List<WeekDate> weekList = mealManager.getMealDate(Integer.parseInt(orgId));
|
|
List<MealCar> mealcarList = mealCarManager.findMealCarListByUserId(userId);
|
|
List<MealCar> mealcarList = mealCarManager.findMealCarListByUserId(userId);
|
|
int sumInt = 0;//总积分
|
|
int sumInt = 0;//总积分
|
|
int sumCount = 0;
|
|
int sumCount = 0;
|
|
@@ -702,7 +701,7 @@ public class OrderDinnerServiceImpl implements OrderDinnerService {
|
|
//没操作下单前只获取当天及之后购物车数据,已超过下单时间只获取今天之后的购物车数据
|
|
//没操作下单前只获取当天及之后购物车数据,已超过下单时间只获取今天之后的购物车数据
|
|
//当下单时间是今天的时候且并没有超过操作时间的数据可以加入到集合中;
|
|
//当下单时间是今天的时候且并没有超过操作时间的数据可以加入到集合中;
|
|
//下单时间的周几大于当天的周几的时候,周三>周二(该为系统当前时间)也可以加入到集合中
|
|
//下单时间的周几大于当天的周几的时候,周三>周二(该为系统当前时间)也可以加入到集合中
|
|
- if ((isOver == 0 && week.getWeekNo() == weekDate) || (week.getWeekNo() > weekDate)) {
|
|
|
|
|
|
+// if ((isOver == 0 && week.getWeekNo() == weekDate) || (week.getWeekNo() > weekDate)) {//--------------------------20220526-----------------------------------
|
|
if (dtoList != null && dtoList.size() > 0) {
|
|
if (dtoList != null && dtoList.size() > 0) {
|
|
dto.setMealCarList(dtoList);
|
|
dto.setMealCarList(dtoList);
|
|
dto.setWeekDate(week);
|
|
dto.setWeekDate(week);
|
|
@@ -720,7 +719,7 @@ public class OrderDinnerServiceImpl implements OrderDinnerService {
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
sumInt = sumInt + reSet.getDayCount();
|
|
sumInt = sumInt + reSet.getDayCount();
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+// }//--------------------------20220526-----------------------------------
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1402,14 +1401,15 @@ public class OrderDinnerServiceImpl implements OrderDinnerService {
|
|
@Override
|
|
@Override
|
|
public AppResultDto exportExcel(String orgId) {
|
|
public AppResultDto exportExcel(String orgId) {
|
|
log.info("begin exportExcel:" + orgId);
|
|
log.info("begin exportExcel:" + orgId);
|
|
|
|
+ String date = DateHelper.formatDate(new Date(),DateHelper.CURRENT_DATE);
|
|
HSSFWorkbook wb = new HSSFWorkbook();
|
|
HSSFWorkbook wb = new HSSFWorkbook();
|
|
try {
|
|
try {
|
|
- List<MealExcelDto> mealList = orderDinnerInfoManager.getOrderExcelListByMeal(orgId);
|
|
|
|
- List<MealExcelDto> deptList = orderDinnerInfoManager.getOrderExcelListByDept(orgId);
|
|
|
|
- List<Map<String, Object>> userList = orderDinnerInfoManager.getOrderExcelListByUserName(orgId);
|
|
|
|
- List<MealExcelDto> addressList = orderDinnerInfoManager.getOrderExcelListByAddress(orgId);
|
|
|
|
|
|
+ List<MealExcelDto> mealList = orderDinnerInfoManager.getOrderExcelListByMeal(orgId,date);
|
|
|
|
+ List<MealExcelDto> deptList = orderDinnerInfoManager.getOrderExcelListByDept(orgId,date);
|
|
|
|
+ List<Map<String, Object>> userList = orderDinnerInfoManager.getOrderExcelListByUserName(orgId,date);
|
|
|
|
+ List<MealExcelDto> addressList = orderDinnerInfoManager.getOrderExcelListByAddress(orgId,date);
|
|
// List<Map<String,Object>> sysList=orderDinnerManager.exportExcelByAddress(orgId);
|
|
// List<Map<String,Object>> sysList=orderDinnerManager.exportExcelByAddress(orgId);
|
|
- List<Map<String, Object>> sysList = orderDinnerManager.exportByAddress(orgId);
|
|
|
|
|
|
+ List<Map<String, Object>> sysList = orderDinnerManager.exportByAddress(orgId,date);
|
|
if (mealList == null || (mealList != null && mealList.size() == 0)) {
|
|
if (mealList == null || (mealList != null && mealList.size() == 0)) {
|
|
return AppResultUtil.createErrorDto("100", "今日没有订单,无法导出");
|
|
return AppResultUtil.createErrorDto("100", "今日没有订单,无法导出");
|
|
}
|
|
}
|
|
@@ -1470,6 +1470,84 @@ public class OrderDinnerServiceImpl implements OrderDinnerService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ public AppResultDto exportExcel2(String orgId,String date) {
|
|
|
|
+ log.info("begin exportExcel2:" + orgId+";date:"+date);
|
|
|
|
+ String nextDate = "";
|
|
|
|
+ if(StringUtils.isEmpty(date)){
|
|
|
|
+ date = DateHelper.formatDate(new Date(),DateHelper.CURRENT_DATE);
|
|
|
|
+ }
|
|
|
|
+ log.info("begin exportExcel2:" + orgId+";date:"+date);
|
|
|
|
+ nextDate = mealManager.getNextMealDate(Integer.parseInt(orgId),date,1);
|
|
|
|
+ log.info("begin exportExcel2:" + orgId+";date:"+date+";nextDate:"+nextDate);
|
|
|
|
+ if(StringUtils.isEmpty(nextDate)){
|
|
|
|
+ nextDate = date;
|
|
|
|
+ log.info("begin exportExcel2:" + orgId+";date:"+date+";nextDate2:"+nextDate);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
|
+ try {
|
|
|
|
+ List<MealExcelDto> mealList = orderDinnerInfoManager.getOrderExcelListByMeal(orgId,nextDate);
|
|
|
|
+ List<MealExcelDto> deptList = orderDinnerInfoManager.getOrderExcelListByDept(orgId,nextDate);
|
|
|
|
+ List<Map<String, Object>> userList = orderDinnerInfoManager.getOrderExcelListByUserName(orgId,nextDate);
|
|
|
|
+ List<MealExcelDto> addressList = orderDinnerInfoManager.getOrderExcelListByAddress(orgId,nextDate);
|
|
|
|
+ List<Map<String, Object>> sysList = orderDinnerManager.exportByAddress(orgId,nextDate);
|
|
|
|
+ if (mealList == null || (mealList != null && mealList.size() == 0)) {
|
|
|
|
+ return AppResultUtil.createErrorDto("100", "今日没有订单,无法导出");
|
|
|
|
+ }
|
|
|
|
+ //设置导出的excel路径
|
|
|
|
+ String path = setPath("upload/OrderExcel"+orgId+".xls");
|
|
|
|
+ File file = new File(new ExcelUtils().getPath(path));
|
|
|
|
+ System.out.println("path:" + path);
|
|
|
|
+ String sheetName = "";
|
|
|
|
+ if (sysList != null && sysList.size() > 0) {
|
|
|
|
+ sheetName = "今日餐品汇总";
|
|
|
|
+ List<Map<String, Object>> mapList = orderDinnerManager.getAllMealName(orgId);
|
|
|
|
+ String[] titles = {"地址", "部门/领导"};
|
|
|
|
+ String[] fieldNames = {"address", "deptname"};
|
|
|
|
+ titles = orderDinnerManager.getTitles(mapList, titles, 1);
|
|
|
|
+ titles = StringUtil.insert(titles, "换花卷");
|
|
|
|
+ titles = StringUtil.insert(titles, "换馒头");
|
|
|
|
+ titles = StringUtil.insert(titles, "合计");
|
|
|
|
+ fieldNames = orderDinnerManager.getTitles(mapList, fieldNames, 2);
|
|
|
|
+ fieldNames = StringUtil.insert(fieldNames, CodeConstants.ROLLS);
|
|
|
|
+ fieldNames = StringUtil.insert(fieldNames, CodeConstants.BUNS);
|
|
|
|
+ fieldNames = StringUtil.insert(fieldNames, "heji");
|
|
|
|
+ file = ExcelUtils.exportExcel(file, wb, sheetName, sysList, titles, fieldNames);
|
|
|
|
+ }
|
|
|
|
+ if (mealList != null && mealList.size() > 0) {
|
|
|
|
+ sheetName = "餐品和数量汇总";
|
|
|
|
+ String[] titles = {"餐品", "数量"};
|
|
|
|
+ String[] fieldNames = {"mName", "other"};
|
|
|
|
+ file = ExcelUtils.exportExcel(file, wb, sheetName, mealList, titles, fieldNames);
|
|
|
|
+ }
|
|
|
|
+ if (addressList != null && addressList.size() > 0) {
|
|
|
|
+ sheetName = "餐品数量和送餐地址汇总";
|
|
|
|
+ String[] titles = {"送餐地址", "餐品"};
|
|
|
|
+ String[] fieldNames = {"other", "mName"};
|
|
|
|
+ file = ExcelUtils.exportExcel(file, wb, sheetName, addressList, titles, fieldNames);
|
|
|
|
+ }
|
|
|
|
+ if (deptList != null && deptList.size() > 0) {
|
|
|
|
+ sheetName = "餐品数量和部门汇总";
|
|
|
|
+ String[] titles = {"部门", "餐品"};
|
|
|
|
+ String[] fieldNames = {"other", "mName"};
|
|
|
|
+ file = ExcelUtils.exportExcel(file, wb, sheetName, deptList, titles, fieldNames);
|
|
|
|
+ }
|
|
|
|
+ if (userList != null && userList.size() > 0) {
|
|
|
|
+ sheetName = "餐品数量和预订人汇总";
|
|
|
|
+ String[] titles = {"部门", "订餐人", "餐品"};
|
|
|
|
+ String[] fieldNames = {"deptname", "other", "mName"};
|
|
|
|
+ file = ExcelUtils.exportExcel(file, wb, sheetName, userList, titles, fieldNames);
|
|
|
|
+ }
|
|
|
|
+ log.info("导出地址:" + path);
|
|
|
|
+ return AppResultUtil.createSuccesDto(path);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("导出失败" + e.getMessage());
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return AppResultUtil.createErrorDto("100", "导出失败:" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public OrderDinner getById(Long id) {
|
|
public OrderDinner getById(Long id) {
|
|
if (orderDinnerManager.exists(id)) {
|
|
if (orderDinnerManager.exists(id)) {
|
|
@@ -1745,15 +1823,6 @@ public class OrderDinnerServiceImpl implements OrderDinnerService {
|
|
if (StringUtils.isNotEmpty(orgIds)) {
|
|
if (StringUtils.isNotEmpty(orgIds)) {
|
|
String[] orgArr = orgIds.split(",");
|
|
String[] orgArr = orgIds.split(",");
|
|
for (String org : orgArr) {
|
|
for (String org : orgArr) {
|
|
-// TbOrganization org = organizationManager.getOrganizationById(Integer.parseInt(orgArr[i]));
|
|
|
|
-// if (null == org) {
|
|
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
-// log.info("getOrderInfoTask/orgName:" + org.getName());
|
|
|
|
-// if ("飞亚达大厦".equals(org.getName())) {
|
|
|
|
-// log.info("getOrderInfoTask/orgArr[i]:" + orgArr[i]);
|
|
|
|
-// orgId = orgArr[i];
|
|
|
|
-// }
|
|
|
|
log.info("getOrderInfoTask/orgId:" + org);
|
|
log.info("getOrderInfoTask/orgId:" + org);
|
|
if (StringUtils.isNotEmpty(org)) {
|
|
if (StringUtils.isNotEmpty(org)) {
|
|
String res = getOrderTime(org, "importTime");
|
|
String res = getOrderTime(org, "importTime");
|
|
@@ -1769,6 +1838,37 @@ public class OrderDinnerServiceImpl implements OrderDinnerService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void getOrderInfoTask2(String orgId,String sysDate) {
|
|
|
|
+ if (StringUtils.isNotEmpty(orgId)) {
|
|
|
|
+ String res = getOrderTime(orgId, "importTime");
|
|
|
|
+ log.info("getOrderInfoTask2-res:{}",res);
|
|
|
|
+ if (StringUtils.isEmpty(res)) {
|
|
|
|
+ } else {
|
|
|
|
+ exportExcel2(orgId,sysDate);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String orgIds = serviceProjectAllocationManager.getServiceProjectByServiceCode("DCFW");
|
|
|
|
+ log.info("getOrderInfoTask/orgIds:" + orgIds);
|
|
|
|
+ if (StringUtils.isNotEmpty(orgIds)) {
|
|
|
|
+ String[] orgArr = orgIds.split(",");
|
|
|
|
+ for (String org : orgArr) {
|
|
|
|
+ log.info("getOrderInfoTask/orgId:" + org);
|
|
|
|
+ if (StringUtils.isEmpty(org)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ String res = getOrderTime(org, "importTime");
|
|
|
|
+ log.info("getOrderInfoTask/res:" + res);
|
|
|
|
+ if (StringUtils.isEmpty(res)) {
|
|
|
|
+ } else {
|
|
|
|
+ redisExport2(org,sysDate);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void redisExport(String orgId) {
|
|
private void redisExport(String orgId) {
|
|
String time = DateHelper.formatDate(new Date(), DateHelper.DATE);
|
|
String time = DateHelper.formatDate(new Date(), DateHelper.DATE);
|
|
log.info("-------------redisExport---time:" + time + "--------------------------");
|
|
log.info("-------------redisExport---time:" + time + "--------------------------");
|
|
@@ -1795,4 +1895,32 @@ public class OrderDinnerServiceImpl implements OrderDinnerService {
|
|
log.info("-----------redisExport-----执行导出结束------------------------");
|
|
log.info("-----------redisExport-----执行导出结束------------------------");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void redisExport2(String orgId,String date) {
|
|
|
|
+ String time = DateHelper.formatDate(new Date(), DateHelper.DATE);
|
|
|
|
+ log.info("-------------redisExport---time:" + time + "--------------------------");
|
|
|
|
+ String key = "getOrder_" + orgId +"_"+ time;
|
|
|
|
+ log.info("-------------redisExport---key:" + key + "--------------------------");
|
|
|
|
+ String mealJson = baseRedisService.get(key);
|
|
|
|
+ log.info("-------------redisExport---mealJson:" + mealJson + "--------------------------");
|
|
|
|
+ int count = 0;
|
|
|
|
+ if (StringUtils.isNotEmpty(mealJson)) {
|
|
|
|
+ log.info("-------------redisExport---redis获取:" + mealJson + "--------------------------");
|
|
|
|
+ count = Integer.parseInt(mealJson);
|
|
|
|
+ count++;
|
|
|
|
+ baseRedisService.set(key, count + "");
|
|
|
|
+ } else {
|
|
|
|
+ count++;
|
|
|
|
+ log.info("-------------redisExport---设置redis---count:" + count + "-----------------------");
|
|
|
|
+ baseRedisService.set(key, count + "");
|
|
|
|
+ log.info("-------------redisExport---设置redis--------------------------");
|
|
|
|
+ }
|
|
|
|
+ log.info("-----------redisExport-----count:" + count + "--------------------------");
|
|
|
|
+ if (count <= 10) {
|
|
|
|
+ log.info("-----------redisExport-----执行导出开始------------------------");
|
|
|
|
+ exportExcel2(orgId,date);
|
|
|
|
+ log.info("-----------redisExport-----执行导出结束------------------------");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|