| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- package com.happy.action;
- import com.alibaba.fastjson.JSONObject;
- import com.happy.Model.Holiday;
- import com.happy.Until.GetHttpParam;
- import com.happy.Until.ResUtil;
- import com.happy.common.controller.BaseController;
- import com.happy.dto.HouseNumberStatusDto;
- import com.happy.service.HouseNumberStatusService;
- import com.opensymphony.xwork2.ModelDriven;
- import lombok.SneakyThrows;
- import org.apache.struts2.ServletActionContext;
- import javax.annotation.Resource;
- import java.util.List;
- import static com.happy.Until.HolidayUtil.getYearHoliday;
- public class HouseNumberStatusAction extends BaseController implements ModelDriven<HouseNumberStatusDto> {
- private final HouseNumberStatusDto houseNumberStatusDto = new HouseNumberStatusDto();
- @Override
- public HouseNumberStatusDto getModel() {
- return houseNumberStatusDto;
- }
- @Resource(name = "HouseNumberStatusService")
- private HouseNumberStatusService houseNumberStatusService;
- /**
- * 根据年份获取节假日数据
- */
- public String queryHoliday() {
- String year = houseNumberStatusDto.getYear();
- if (year.length() > 4) {
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "请输入年份");
- put("code", 500);
- }}.toString());
- return null;
- }
- if (year == null) {
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "请传入参数");
- put("code", 500);
- }}.toString());
- return null;
- }
- List<Holiday> days = getYearHoliday("2023");
- if (days == null) {
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "第三方接口调用失败");
- put("code", 500);
- }}.toString());
- return null;
- }
- if (days.size() <= 0) {
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "第三方接口调用失败");
- put("code", 500);
- }}.toString());
- return null;
- }
- houseNumberStatusService.deleteHolidayByYear(year);
- int lenegth = houseNumberStatusService.saveHolidayBatch(days);
- if (lenegth <= 0) {
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "节假日数据存储失败");
- put("code", 500);
- }}.toString());
- return null;
- }
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "节假日数据存储成功");
- put("code", 200);
- }}.toString());
- return null;
- }
- /**
- * 表格数据 房态管理-房态管理
- */
- public void queryData() {
- JSONObject objects = houseNumberStatusService.queryData(houseNumberStatusDto,page,rows);
- if (objects != null) {
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "请求成功");
- put("code", 200);
- put("data", objects);
- }}.toString());
- } else {
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "该房型未新增房间号");
- put("code", 200);
- }}.toString());
- }
- }
- /**
- * 查询可置脏/净、可开/关的房型及房间号 房态管理-房态管理
- */
- public void queryListWithHouse() {
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "请求成功");
- put("code", 200);
- put("data", houseNumberStatusService.queryListWithHouse(houseNumberStatusDto));
- }}.toString());
- }
- /**
- * 批量开/关房 房态管理-房态管理
- */
- @SneakyThrows
- public void modifyStatusBatch() {
- String postDataStr = GetHttpParam.getRequestPostData(request);
- HouseNumberStatusDto postDataObj = JSONObject.parseObject(postDataStr, HouseNumberStatusDto.class);
- //2023-09-20 A-jax 参数判断
- if(postDataObj.getHouseNumberIds() == null){
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "房间不能为空");
- put("code", 500);
- }}.toString());
- }
- if(postDataObj.getStatus() == 2 && postDataObj.getCreateId() == null){
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "关房类型不能为空");
- put("code", 500);
- }}.toString());
- }
- if(postDataObj.getSetDate() == null){
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "日期不能为空");
- put("code", 500);
- }}.toString());
- }
- houseNumberStatusService.modifyStatusBatch(postDataObj);
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "请求成功");
- put("code", 200);
- }}.toString());
- }
- /**
- * 开/关房 房态管理-房态管理
- */
- @SneakyThrows
- public void modifyStatus() {
- if(houseNumberStatusDto.getCloseType() == null){
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "关房类型不能为空");
- put("code", 500);
- }}.toString());
- }
- houseNumberStatusService.modifyStatus(houseNumberStatusDto);
- ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
- put("message", "请求成功");
- put("code", 200);
- }}.toString());
- }
- }
|