|
|
@@ -1,7 +1,9 @@
|
|
|
package org.jeecg.modules.system.app.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
@@ -11,16 +13,25 @@ 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.query.QueryGenerator;
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.modules.system.app.dto.AppTeachingTimeDTO;
|
|
|
+import org.jeecg.modules.system.app.dto.TeachingDayDTO;
|
|
|
+import org.jeecg.modules.system.app.entity.AppSite;
|
|
|
+import org.jeecg.modules.system.app.entity.AppSitePriceRules;
|
|
|
import org.jeecg.modules.system.app.entity.AppTeachingTime;
|
|
|
+import org.jeecg.modules.system.app.service.IAppSitePriceRulesService;
|
|
|
+import org.jeecg.modules.system.app.service.IAppSiteService;
|
|
|
import org.jeecg.modules.system.app.service.IAppTeachingTimeService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -36,7 +47,11 @@ import java.util.List;
|
|
|
public class AppTeachingTimeController extends JeecgController<AppTeachingTime, IAppTeachingTimeService> {
|
|
|
@Autowired
|
|
|
private IAppTeachingTimeService appTeachingTimeService;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private IAppSitePriceRulesService appSitePriceRulesService;
|
|
|
+ @Resource
|
|
|
+ private IAppSiteService appSiteService;
|
|
|
+
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
*
|
|
|
@@ -60,7 +75,7 @@ public class AppTeachingTimeController extends JeecgController<AppTeachingTime,
|
|
|
IPage<AppTeachingTime> pageList = appTeachingTimeService.page(page, queryWrapper);
|
|
|
return Result.OK(pageList);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 添加
|
|
|
*
|
|
|
@@ -76,7 +91,7 @@ public class AppTeachingTimeController extends JeecgController<AppTeachingTime,
|
|
|
|
|
|
return Result.OK("添加成功!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 编辑
|
|
|
*
|
|
|
@@ -91,7 +106,53 @@ public class AppTeachingTimeController extends JeecgController<AppTeachingTime,
|
|
|
appTeachingTimeService.updateById(appTeachingTime);
|
|
|
return Result.OK("编辑成功!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param appTeachingTime
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "教学/非教学维护表-编辑是否教学日")
|
|
|
+ @Operation(summary="教学/非教学维护表-编辑是否教学日")
|
|
|
+ @RequestMapping(value = "/editOrTeachingDay", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
+ public Result<String> editOrTeachingDay(@RequestBody AppTeachingTime appTeachingTime) {
|
|
|
+ AppTeachingTime teachingTime = appTeachingTimeService.getById(appTeachingTime.getId());
|
|
|
+ //修改对应学校的site_price_rules
|
|
|
+ String tenantId = teachingTime.getTenantId();
|
|
|
+ Date day = teachingTime.getDay();
|
|
|
+ AppSitePriceRules sitePriceRules = appSitePriceRulesService.getOne(Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getTenantId, tenantId).eq(AppSitePriceRules::getDateOfSale, day).last("limit 1"));
|
|
|
+ if (sitePriceRules != null) {
|
|
|
+
|
|
|
+ AppSite site = appSiteService.getOne(Wrappers.<AppSite>lambdaQuery().eq(AppSite::getTenantId, tenantId).last("limit 1"));
|
|
|
+
|
|
|
+ sitePriceRules.setIsTeaching(appTeachingTime.getIsTeaching());
|
|
|
+ if (site != null) {
|
|
|
+ if (appTeachingTime.getIsTeaching().equals(1)){
|
|
|
+ List<TeachingDayDTO> data = JSONObject.parseObject(site.getNoTeachingDay()).getJSONArray("data").toJavaList(TeachingDayDTO.class);
|
|
|
+ data.forEach(item -> {
|
|
|
+ Date startTime = DateUtils.str2Date(item.getStartTime(), new SimpleDateFormat("HH:mm"));
|
|
|
+ Date endTime = DateUtils.str2Date(item.getEndTime(), new SimpleDateFormat("HH:mm"));
|
|
|
+ sitePriceRules.setStartTime(startTime);
|
|
|
+ sitePriceRules.setEndTime(endTime);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (appTeachingTime.getIsTeaching().equals(0)){
|
|
|
+ List<TeachingDayDTO> data = JSONObject.parseObject(site.getTeachingDay()).getJSONArray("data").toJavaList(TeachingDayDTO.class);
|
|
|
+ data.forEach(item -> {
|
|
|
+ Date startTime = DateUtils.str2Date(item.getStartTime(), new SimpleDateFormat("HH:mm"));
|
|
|
+ Date endTime = DateUtils.str2Date(item.getEndTime(), new SimpleDateFormat("HH:mm"));
|
|
|
+ sitePriceRules.setStartTime(startTime);
|
|
|
+ sitePriceRules.setEndTime(endTime);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ appSitePriceRulesService.updateById(sitePriceRules);
|
|
|
+ }
|
|
|
+ appTeachingTimeService.updateById(appTeachingTime);
|
|
|
+ return Result.OK("编辑成功!");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 通过id删除
|
|
|
*
|
|
|
@@ -106,7 +167,7 @@ public class AppTeachingTimeController extends JeecgController<AppTeachingTime,
|
|
|
appTeachingTimeService.removeById(id);
|
|
|
return Result.OK("删除成功!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 批量删除
|
|
|
*
|
|
|
@@ -121,7 +182,7 @@ public class AppTeachingTimeController extends JeecgController<AppTeachingTime,
|
|
|
this.appTeachingTimeService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
return Result.OK("批量删除成功!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 通过id查询
|
|
|
*
|