|
@@ -0,0 +1,180 @@
|
|
|
|
+package com.idea.pro.wx.controller.buildManage;
|
|
|
|
+
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
|
+import com.idea.buildManage.excel.ParkRoomExcel;
|
|
|
|
+import com.idea.buildManage.excel.ParkRoomListener;
|
|
|
|
+import com.idea.buildManage.model.ParkRoom;
|
|
|
|
+import com.idea.buildManage.response.ParkRoomResponse;
|
|
|
|
+import com.idea.buildManage.service.MnpBuildingService;
|
|
|
|
+import com.idea.buildManage.service.ParkFloorDiscService;
|
|
|
|
+import com.idea.buildManage.service.ParkInfoService;
|
|
|
|
+import com.idea.buildManage.service.ParkRoomService;
|
|
|
|
+import com.idea.util.ExcelUtils;
|
|
|
|
+import com.rockstar.common.base.BaseController;
|
|
|
|
+import com.rockstar.common.domain.AjaxResult;
|
|
|
|
+import com.rockstar.frame.model.extend.DateTrans;
|
|
|
|
+import com.rockstar.frame.model.extend.TableSplitResult;
|
|
|
|
+import com.rockstar.frame.model.extend.Tablepar;
|
|
|
|
+import com.rockstar.system.service.SysDictService;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Created by pengyq on 2020.
|
|
|
|
+ */
|
|
|
|
+@Slf4j
|
|
|
|
+@Controller
|
|
|
|
+@RequestMapping(value = "/wx/ParkRoomController")
|
|
|
|
+@Api(value = "房间管理")
|
|
|
|
+public class WxParkRoomController extends BaseController {
|
|
|
|
+
|
|
|
|
+ //主表
|
|
|
|
+ @Autowired
|
|
|
|
+ private ParkRoomService modelService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private MnpBuildingService buildingService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ParkFloorDiscService floorDiscService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ParkInfoService parkInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysDictService sysDictService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @PostMapping(value = "list", produces = {"application/json;charset=UTF-8"})
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public Object list(Tablepar tablepar, ParkRoom model, DateTrans dt) {
|
|
|
|
+ PageInfo<ParkRoom> page = modelService.list(tablepar, model, dt);
|
|
|
|
+ TableSplitResult<ParkRoom> result = new TableSplitResult<ParkRoom>(page.getPageNum(), page.getTotal(), page.getList());
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "房间列表")
|
|
|
|
+ @PostMapping(value = "listAll", produces = {"application/json;charset=UTF-8"})
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public Object listAll(ParkRoom model, DateTrans dt) {
|
|
|
|
+ return modelService.listAll(model, dt);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "新增房间")
|
|
|
|
+ @PostMapping(value = "add", produces = {"application/json;charset=UTF-8"})
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public AjaxResult add(ParkRoom record) {
|
|
|
|
+
|
|
|
|
+ int result = modelService.add(record);
|
|
|
|
+ return result(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "删除房间")
|
|
|
|
+ @PostMapping(value = "remove/{id}", produces = {"application/json;charset=UTF-8"})
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public AjaxResult remove(@PathVariable("id") String id) {
|
|
|
|
+ int result = modelService.deleteByPrimaryKey(id);
|
|
|
|
+ return result(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "编辑房间")
|
|
|
|
+ @PostMapping(value = "edit", produces = {"application/json;charset=UTF-8"})
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public AjaxResult editSave(ParkRoom model) {
|
|
|
|
+ int result = modelService.edit(model);
|
|
|
|
+ return result(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "查询房间")
|
|
|
|
+ @PostMapping(value = "getById", produces = {"application/json;charset=UTF-8"})
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public ParkRoom getById(String id) {
|
|
|
|
+ return modelService.selectByPrimaryKey(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "房间列表分页")
|
|
|
|
+ @PostMapping(value = "listByModel", produces = {"application/json;charset=UTF-8"})
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public Object listByModel(Tablepar tablepar, ParkRoomResponse model, DateTrans dt) {
|
|
|
|
+ PageInfo<ParkRoomResponse> page = modelService.listByModel(tablepar, model, dt);
|
|
|
|
+ TableSplitResult<ParkRoomResponse> result = new TableSplitResult<ParkRoomResponse>(page.getPageNum(), page.getTotal(), page.getList());
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "全房间列表")
|
|
|
|
+ @PostMapping(value = "excelList", produces = {"application/json;charset=UTF-8"})
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public Object excelList(ParkRoomResponse model) {
|
|
|
|
+ return success(modelService.excelList(model, null));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取房屋面积
|
|
|
|
+ *
|
|
|
|
+ * @param ids
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "getAreaByIds", produces = {"application/json;charset=UTF-8"})
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public Double getAreaByIds(String ids) {
|
|
|
|
+
|
|
|
|
+ return modelService.getAreaByIds(ids);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 房间导入
|
|
|
|
+ *
|
|
|
|
+ * @param file
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "handleImport", produces = {"application/json;charset=UTF-8"})
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public AjaxResult handleImport(@RequestParam("file") MultipartFile file) {
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ ParkRoomListener listener = new ParkRoomListener(modelService, buildingService, floorDiscService, parkInfoService, sysDictService, jsonObject);
|
|
|
|
+ try {
|
|
|
|
+ ExcelUtils excelUtils = new ExcelUtils();
|
|
|
|
+ File excel = excelUtils.multipartFileToFile(file);
|
|
|
|
+ if (null == excel) {
|
|
|
|
+ return AjaxResult.error("导入失败");
|
|
|
|
+ }
|
|
|
|
+ EasyExcel.read(excel, ParkRoomExcel.class, listener).headRowNumber(1).sheet().doRead();
|
|
|
|
+ excel.delete();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return AjaxResult.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success(jsonObject);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "房间删除")
|
|
|
|
+ @PostMapping(value = "delete", produces = {"application/json;charset=UTF-8"})
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public AjaxResult delete(String id) {
|
|
|
|
+ int result = modelService.delete(id);
|
|
|
|
+ return result(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导出
|
|
|
|
+ *
|
|
|
|
+ * @param list
|
|
|
|
+ * @param response
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "errorListExport")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public void errorListExport(@RequestBody List<ParkRoomExcel> list, HttpServletResponse response) throws IOException {
|
|
|
|
+ modelService.errorListExport(list, response);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|