|
@@ -4,8 +4,10 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ylx.common.constant.MassageConstants;
|
|
|
+import com.ylx.common.core.domain.entity.SysDept;
|
|
|
import com.ylx.common.utils.StringUtils;
|
|
|
import com.ylx.massage.domain.TJs;
|
|
|
+import com.ylx.massage.domain.TJsDay;
|
|
|
import com.ylx.massage.domain.TOrder;
|
|
|
import com.ylx.massage.domain.TSign;
|
|
|
import com.ylx.massage.enums.JsStatusEnum;
|
|
@@ -14,10 +16,13 @@ import com.ylx.massage.service.TJsService;
|
|
|
import com.ylx.massage.service.TOrderService;
|
|
|
import com.ylx.massage.service.TSignService;
|
|
|
import com.ylx.massage.utils.DateTimeUtils;
|
|
|
+import com.ylx.system.service.ISysDeptService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -39,6 +44,9 @@ public class massageTask {
|
|
|
@Resource
|
|
|
private TSignService signService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService deptService;
|
|
|
+
|
|
|
|
|
|
public void cancelOrder() {
|
|
|
|
|
@@ -127,7 +135,7 @@ public class massageTask {
|
|
|
if (CollectionUtil.isNotEmpty(page1.getRecords())) {
|
|
|
page1.getRecords().forEach(tjs -> {
|
|
|
List<TOrder> list = orderService.list(new LambdaQueryWrapper<TOrder>().eq(TOrder::getcJsId, tjs.getId()).ge(TOrder::getDtCreateTime, date));
|
|
|
- if(CollectionUtil.isEmpty(list) || list.size() < 3){
|
|
|
+ if (CollectionUtil.isEmpty(list) || list.size() < 3) {
|
|
|
TJs js = new TJs();
|
|
|
js.setId(tjs.getId());
|
|
|
js.setnB3(MassageConstants.INTEGER_ZERO);
|
|
@@ -147,28 +155,72 @@ public class massageTask {
|
|
|
* 插入一条(前一天)下岗记录(并计算在线时长) 和当天上岗记录
|
|
|
*
|
|
|
* @param date yyyy-MM-dd
|
|
|
- *
|
|
|
- *
|
|
|
- **/
|
|
|
+ **/
|
|
|
public void RegularLayoff(String date) {
|
|
|
|
|
|
Date date2 = new Date();
|
|
|
- if(StringUtils.isNotBlank(date)){
|
|
|
+ if (StringUtils.isNotBlank(date)) {
|
|
|
date2 = DateTimeUtils.parseDate(date, DateTimeUtils.DATE_FORMAT);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
date2 = DateTimeUtils.addDays(date2, -1);
|
|
|
}
|
|
|
-
|
|
|
- Page<TSign> signPage = new Page<>();
|
|
|
- signPage.setSize(MassageConstants.TWO_HUNDRED);
|
|
|
- LambdaQueryWrapper<TSign> signLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- //上岗
|
|
|
Date startDate = DateTimeUtils.getStartDate(date2);
|
|
|
Date endDate = DateTimeUtils.getEndDate(date2);
|
|
|
-
|
|
|
-// signLambdaQueryWrapper.eq(TSign::getDutyStatus, JsStatusEnum.POST_ON_DUTY.getCode()).ge(TSign::getSingTime, startDate).le(TSign::getSingTime, endDate);
|
|
|
-// Page<TSign> page = signService.page(signPage, signLambdaQueryWrapper);
|
|
|
-
|
|
|
+ long total = 1L;
|
|
|
+ while (total > 0L) {
|
|
|
+ Page<TSign> signPage = new Page<>();
|
|
|
+ signPage.setSize(MassageConstants.TWO_HUNDRED);
|
|
|
+ LambdaQueryWrapper<TSign> signLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //上岗
|
|
|
+
|
|
|
+ signLambdaQueryWrapper.isNull(TSign::getLayoffTime).ge(TSign::getSingTime, startDate).le(TSign::getSingTime, endDate);
|
|
|
+ Page<TSign> page = signService.page(signPage, signLambdaQueryWrapper);
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(page.getRecords())) {
|
|
|
+ page.getRecords().forEach(sign -> {
|
|
|
+
|
|
|
+ sign.setLayoffTime(endDate);
|
|
|
+ Long layoff = DateTimeUtils.dateToStamp(sign.getLayoffTime());
|
|
|
+ Long sing = DateTimeUtils.dateToStamp(sign.getSingTime());
|
|
|
+ Long time = layoff - sing;
|
|
|
+ time = time / 1000;
|
|
|
+ time = time / 60;
|
|
|
+ sign.setOnlineTime(time.intValue());
|
|
|
+ signService.updateById(sign);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ total = page.getTotal();
|
|
|
+ }
|
|
|
+ //查询所有部门
|
|
|
+ List<SysDept> sysDepts = deptService.selectDeptList(null);
|
|
|
+
|
|
|
+ sysDepts.forEach(sysDept -> {
|
|
|
+ //查询所有技师
|
|
|
+ LambdaQueryWrapper<TJs> jsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ jsLambdaQueryWrapper.eq(TJs::getnTong, JsStatusEnum.JS_PASS.getCode()).eq(TJs::getDeptId, sysDept.getDeptId());
|
|
|
+ List<TJs> jsList = jsService.list(jsLambdaQueryWrapper);
|
|
|
+ if (CollectionUtil.isNotEmpty(jsList)) {
|
|
|
+ jsList.forEach(js -> {
|
|
|
+ TJsDay tJsDay = new TJsDay();
|
|
|
+ tJsDay.setDeptName(js.getCity());
|
|
|
+ tJsDay.setDeptId(js.getDeptId());
|
|
|
+ tJsDay.setOpenId(js.getcOpenId());
|
|
|
+ tJsDay.setJsId(js.getId());
|
|
|
+ tJsDay.setName(js.getcName());
|
|
|
+ Integer onLine =signService.getOnLineTime(js.getId(),startDate,endDate);
|
|
|
+ tJsDay.setOnLine(onLine);
|
|
|
+ Integer orderNum = orderService.getOrderNum(js.getId(),startDate,endDate);
|
|
|
+ tJsDay.setOrderNum(orderNum);
|
|
|
+ Integer addNum = orderService.getAddNum(js.getId(),startDate,endDate);
|
|
|
+ tJsDay.setAddNum(addNum);
|
|
|
+ Integer upgradeNum = orderService.getUpgradeNum(js.getId(),startDate,endDate);
|
|
|
+ tJsDay.setUpgradeNum(upgradeNum);
|
|
|
+ BigDecimal turnover = orderService.getTurnover(js.getId(),startDate,endDate);
|
|
|
+ tJsDay.setTurnover(turnover);
|
|
|
+ tJsDay.setRecharge(0.0);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
|
|
|
}
|