|
@@ -0,0 +1,176 @@
|
|
|
|
+package com.charging.chargingparking.modules.mobileController;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.charging.chargingparking.dto.MessageResult;
|
|
|
|
+import com.charging.chargingparking.dto.ParkTimeDTO;
|
|
|
|
+import com.charging.chargingparking.dto.ParkTimeStatusDTO;
|
|
|
|
+import com.charging.chargingparking.dto.PojoUtils;
|
|
|
|
+import com.charging.chargingparking.entity.*;
|
|
|
|
+import com.charging.chargingparking.modules.common.dto.Sort;
|
|
|
|
+import com.charging.chargingparking.service.*;
|
|
|
|
+import com.charging.chargingparking.utils.StringUtils;
|
|
|
|
+import com.github.pagehelper.Page;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author hbjzws
|
|
|
|
+ * @date 2023/10/25 0002 下午 4:41
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@Slf4j
|
|
|
|
+@RequestMapping("/parkingTime")
|
|
|
|
+public class ParkingTimeController {
|
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ParkingInfoService parkingInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ParkingMemberService parkingMemberOrgService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ParkingTimeService parkingTimeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private TimeSetService timeSetService;
|
|
|
|
+ @ApiOperation(value = "节假日列表")
|
|
|
|
+ @RequestMapping(value = "timeSetList", method = RequestMethod.POST)
|
|
|
|
+ public MessageResult<List> timeSetList() {
|
|
|
|
+ MessageResult<List> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ List<TimeSet> list=timeSetService.list();
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(list);
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+ @ApiOperation(value = "节假日已设置")
|
|
|
|
+ @RequestMapping(value = "getTimeSetList", method = RequestMethod.POST)
|
|
|
|
+ public MessageResult<List> getTimeSetList(String parkId) {
|
|
|
|
+ MessageResult<List> msgResult = new MessageResult<>();
|
|
|
|
+ List<ParkingTime> listParkingTime = parkingTimeService.list(new QueryWrapper<ParkingTime>().eq("park_id", parkId).eq("is_custom",false).eq("del_flag",false));
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(listParkingTime);
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+ @ApiOperation(value = "停车场时间设置状态")
|
|
|
|
+ @RequestMapping(value = "getParkInfoTimeStatus", method = RequestMethod.POST)
|
|
|
|
+ public MessageResult<ParkTimeStatusDTO> getParkInfoTimeStatus(String parkId) {
|
|
|
|
+ MessageResult<ParkTimeStatusDTO> msgResult = new MessageResult<>();
|
|
|
|
+ ParkingInfo parkingInfo = parkingInfoService.getById(parkId);
|
|
|
|
+ ParkTimeStatusDTO parkTimeStatusDTO = new ParkTimeStatusDTO();
|
|
|
|
+ parkTimeStatusDTO.setStarTimeFlag(parkingInfo.getStarTimeFlag());
|
|
|
|
+ parkTimeStatusDTO.setStartYear(parkingInfo.getStartYear());
|
|
|
|
+ parkTimeStatusDTO.setEndYear(parkingInfo.getEndYear());
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(parkTimeStatusDTO);
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+ @ApiOperation(value = "停车场节假日设置")
|
|
|
|
+ @RequestMapping(value = "saveSet", method = RequestMethod.POST)
|
|
|
|
+ public MessageResult<Boolean> saveSet(@RequestBody ParkTimeDTO parkTimeDTO, @RequestAttribute String subject) {
|
|
|
|
+ // public MessageResult<Boolean> saveSet(@RequestBody ParkTimeDTO parkTimeDTO) {
|
|
|
|
+ MessageResult<Boolean> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ List<String> list =parkTimeDTO.getListSetId();
|
|
|
|
+ ParkingInfo parkingInfo = parkingInfoService.getById(parkTimeDTO.getParkId());
|
|
|
|
+ parkingInfo.setStarTimeFlag(parkTimeDTO.getStarTimeFlag());
|
|
|
|
+ parkingInfo.setStartYear(parkTimeDTO.getStartYear());
|
|
|
|
+ parkingInfo.setEndYear(parkTimeDTO.getEndYear());
|
|
|
|
+ parkingInfoService.update(parkingInfo);
|
|
|
|
+ //保存前先删除之前的非自定义的数据
|
|
|
|
+ List<ParkingTime> listParkingTime = parkingTimeService.list(new QueryWrapper<ParkingTime>().eq("park_id", parkTimeDTO.getParkId()).eq("is_custom",false).eq("del_flag",false));
|
|
|
|
+ for(ParkingTime parkingTime:listParkingTime){
|
|
|
|
+ parkingTime.setDelFlag(true);
|
|
|
|
+ parkingTimeService.removeById(parkingTime);
|
|
|
|
+ }
|
|
|
|
+ for(String setId:list){
|
|
|
|
+ ParkingTime parkingTime = new ParkingTime();
|
|
|
|
+ parkingTime.setIsCustom(false);
|
|
|
|
+ parkingTime.setParkId(parkTimeDTO.getParkId());
|
|
|
|
+ parkingTime.setSetId(setId);
|
|
|
|
+ parkingTime.setCreateTime(new Date());
|
|
|
|
+ parkingTime.setCreateBy(subject);
|
|
|
|
+ parkingTime.setUpdateTime(new Date());
|
|
|
|
+ parkingTime.setUpdateBy(subject);
|
|
|
|
+ parkingTimeService.save(parkingTime);
|
|
|
|
+ }
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(true);
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+ @ApiOperation(value = "停车场自定义时间设置")
|
|
|
|
+ @RequestMapping(value = "saveSingleSet", method = RequestMethod.POST)
|
|
|
|
+ public void saveSingleSet(@RequestBody ParkingTime parkingTime, @RequestAttribute String subject) {
|
|
|
|
+// public void saveSingleSet(@RequestBody ParkingTime parkingTime) {
|
|
|
|
+// ParkingTime parkingTime = new ParkingTime();
|
|
|
|
+// parkingTime.setParkId("1");
|
|
|
|
+// parkingTime.setIsCustom(true);
|
|
|
|
+// parkingTime.setStartTime(new Date());
|
|
|
|
+// parkingTime.setEndTime(new Date());
|
|
|
|
+ parkingTime.setIsCustom(true);
|
|
|
|
+ parkingTime.setCreateTime(new Date());
|
|
|
|
+ parkingTime.setCreateBy(subject);
|
|
|
|
+ parkingTime.setUpdateTime(new Date());
|
|
|
|
+ parkingTime.setUpdateBy(subject);
|
|
|
|
+ parkingTimeService.save(parkingTime);
|
|
|
|
+ }
|
|
|
|
+ @ApiOperation(value = "删除")
|
|
|
|
+ @PostMapping("deleteSingleSet/{id}")
|
|
|
|
+ // public MessageResult<Boolean> deleteSingleSet(@PathVariable("id") String id, @RequestAttribute String subject) {
|
|
|
|
+ public MessageResult<Boolean> deleteSingleSet(@PathVariable("id") String id) {
|
|
|
|
+
|
|
|
|
+ MessageResult<Boolean> msgResult = new MessageResult<>();
|
|
|
|
+ try {
|
|
|
|
+ ParkingTime parkingTime = parkingTimeService.getById(id);
|
|
|
|
+ parkingTime.setDelFlag(true);
|
|
|
|
+ boolean flag = parkingTimeService.removeById(parkingTime);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(flag);
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
|
+ @RequestMapping(value = "pageSingleSetList", method = RequestMethod.POST)
|
|
|
|
+ public MessageResult<Map> pageSingleSetList(
|
|
|
|
+ String parkId,
|
|
|
|
+ @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "20") int pageSize
|
|
|
|
+ ) {
|
|
|
|
+ // @RequestAttribute String subject
|
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
|
+ sortList.add(new Sort("a.create_time", "desc"));
|
|
|
|
+
|
|
|
|
+ if (com.charging.chargingparking.utils.StringUtils.isNotEmpty(parkId)) {
|
|
|
|
+ searchParams.put("parkId", parkId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Page<ParkingTime> page = parkingTimeService.pageSearch(searchParams, pageIndex, pageSize, sortList);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+}
|