From c2976b80e8850be2d28dc2132c6659856b871f3c Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期四, 08 五月 2025 21:10:42 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java | 364 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 364 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java
new file mode 100644
index 0000000..399d528
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java
@@ -0,0 +1,364 @@
+package com.dy.pipIrrProject.intake;
+
+import com.alibaba.excel.EasyExcel;
+import com.dy.common.aop.SsoAop;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.common.webUtil.ResultCodeMsg;
+import com.dy.pipIrrGlobal.excel.CellWriteHandler;
+import com.dy.pipIrrGlobal.excel.ExcelUtil;
+import com.dy.pipIrrGlobal.pojoPr.PrIntake;
+import com.dy.pipIrrGlobal.voPr.*;
+import com.dy.pipIrrGlobal.voSe.VoActiveCard;
+import com.dy.pipIrrProject.intake.qo.QoIntake;
+import com.dy.pipIrrProject.result.ProjectResultCode;
+import com.taobao.api.ApiException;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.Valid;
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.MediaType;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+
+/**
+ * @author WuZeYu
+ * @date 2023/12/26 20:11
+ * @LastEditTime 2023/12/20 20:11
+ * @Description
+ */
+
+@Slf4j
+@Tag(name = "鍙栨按鍙g鐞�", description = "鍙栨按鍙f搷浣�")
+@RestController
+@RequestMapping(path = "intake")
+@RequiredArgsConstructor
+public class IntakeCtrl {
+ private final IntakeSv intakeSv;
+
+ @GetMapping("/test")
+ public String sendMessage(String message) throws ApiException {
+ return intakeSv.sendMessage(message);
+ }
+
+ /**
+ * 瀹㈡埛绔姹傚緱鍒版墍鏈夊彇姘村彛鍚嶅瓧
+ *
+ * @return 鎵�鏈夊彇姘村彛鍚嶅瓧
+ */
+ @Operation(summary = "鑾峰緱鍏ㄩ儴鍙栨按鍙�", description = "杩斿洖鍏ㄩ儴鍙栨按鍙f暟鎹�")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "杩斿洖鍏ㄩ儴鍙栨按鍙f暟鎹紙BaseResponse.content:QueryResultVo[{}]锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = PrIntake.class))}
+ )
+ })
+ @GetMapping(path = "all")
+ @SsoAop()
+ public BaseResponse<QueryResultVo<List<VoAllIntake>>> all() {
+ try {
+ QueryResultVo<List<VoAllIntake>> res = this.intakeSv.selectAll();
+ if (res == null) {
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_INTAKES.getMessage());
+ } else {
+ return BaseResponseUtils.buildSuccess(res);
+ }
+ } catch (Exception e) {
+ log.error("鏌ヨ鍙栨按鍙e紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 寰楀埌涓�涓彇姘村彛鏁版嵁
+ *
+ * @return 涓�涓彇姘村彛鏁版嵁
+ */
+ @Operation(summary = "涓�涓彇姘村彛", description = "寰楀埌涓�涓彇姘村彛鏁版嵁")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "杩斿洖涓�涓彇姘村彛鏁版嵁锛圔aseResponse.content:{}锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = PrIntake.class))}
+ )
+ })
+ @GetMapping(path = "one")
+ @SsoAop()
+ public BaseResponse<VoAllIntake> one(@RequestParam("id") Long id) {
+ if (this.intakeSv.selectById(id) == null) {
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_INTAKES.getMessage());
+ } else {
+ return BaseResponseUtils.buildSuccess(this.intakeSv.selectById(id));
+ }
+ }
+
+ @Operation(summary = "鑾峰緱涓�椤靛彇姘村彛璁板綍", description = "杩斿洖涓�椤靛彇姘村彛鏁版嵁")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "杩斿洖涓�椤靛彇姘村彛鏁版嵁锛圔aseResponse.content:QueryResultVo[{}]锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = VoActiveCard.class))}
+ )
+ })
+ @GetMapping(path = "getIntakes")
+ @SsoAop()
+ public BaseResponse<QueryResultVo<List<VoIntake>>> getIntakes(QueryVo vo) {
+ try {
+ return BaseResponseUtils.buildSuccess(intakeSv.getIntakes(vo));
+ } catch (Exception e) {
+ log.error("鑾峰彇鍙栨按鍙h褰曞紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ @Operation(summary = "娣诲姞鍙栨按鍙h褰�", description = "娣诲姞鍙栨按鍙h褰�")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = Boolean.class))}
+ )
+ })
+ @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ public BaseResponse<Boolean> add(@RequestBody @Valid PrIntake po, @Parameter(hidden = true) BindingResult bindingResult) {
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ List<Long> ids = intakeSv.getIntakeIdsByName(po.getName());
+ if (ids.size() > 0) {
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.INTAKE_NAME_EXIST.getMessage());
+ }
+ po.setOperateDt(new Date());
+ po.setDeleted((byte) 0);
+ Integer rec = Optional.ofNullable(intakeSv.addIntake(po)).orElse(0);
+ if (rec == 0) {
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.ADD_INTAKE_FAIL.getMessage());
+ }
+ return BaseResponseUtils.buildSuccess(true);
+ }
+
+ /**
+ * 缂栬緫淇敼鍙栨按鍙�
+ *
+ * @param po 淇濆瓨鍙栨按鍙orm琛ㄥ崟瀵硅薄
+ * @return 鏄惁鎴愬姛
+ */
+ @Operation(summary = "缂栬緫淇敼鍙栨按鍙�", description = "鎻愪氦鍙栨按鍙f暟鎹紙form琛ㄥ崟锛夛紝杩涜淇敼")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = Boolean.class))}
+ )
+ })
+ @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @SsoAop()
+ public BaseResponse<Boolean> update(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid PrIntake po, @Parameter(hidden = true) BindingResult bindingResult) {
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ List<Long> ids = intakeSv.getIntakeIdByNameExcludeId(po.getId(), po.getName());
+ if (ids.size() > 0) {
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.INTAKE_NAME_EXIST.getMessage());
+ }
+ int count;
+ po.setOperateDt(new Date());
+ try {
+ count = this.intakeSv.update(po);
+ } catch (Exception e) {
+ log.error("淇濆瓨鍙栨按鍙e紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ if (count <= 0) {
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.UPDATE_INTAKE.getMessage());
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
+ }
+
+ /**
+ * app淇敼鍙栨按鍙g粡绾害
+ * @param po
+ * @param bindingResult
+ * @return
+ */
+ @PostMapping(path = "updateIntakeLngLat", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @SsoAop()
+ public BaseResponse<Boolean> updateIntakeLngLat(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid IntakeUpdateLngLat po, @Parameter(hidden = true) BindingResult bindingResult) {
+ if (bindingResult != null && bindingResult.hasErrors()) {
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ int count;
+ po.setOperateDt(new Date());
+ try {
+ count = this.intakeSv.updateIntakeLngLat(po);
+ } catch (Exception e) {
+ log.error("淇濆瓨鍙栨按鍙g粡绾害寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ if (count <= 0) {
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.UPDATE_INTAKE.getMessage());
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
+ }
+
+ /**
+ * 鍒犻櫎鍙栨按鍙�
+ *
+ * @param map 鍙栨按鍙D
+ * @return 鏄惁鎴愬姛
+ */
+ @Operation(summary = "鍒犻櫎鍒嗘按鍙�", description = "鎻愪氦鍙栨按鍙D锛岃繘琛岄�昏緫鍒犻櫎")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = Boolean.class))}
+ )
+ })
+ @PostMapping(path = "delete")
+ @SsoAop()
+ public BaseResponse<Boolean> delete(@RequestBody Map map) {
+ if (map == null || map.size() <= 0) {
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.PLEASE_INPUT_INTAKE_ID.getMessage());
+ }
+ Long id = Long.parseLong(map.get("id").toString());
+ try {
+ //鍙栨按鍙D
+ Integer recordCount = Optional.ofNullable(intakeSv.delete(id)).orElse(0);
+ if (recordCount == 0) {
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_INTAKE_FAIL.getMessage());
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
+ } catch (Exception e) {
+ log.error("淇濆瓨鍒嗘按鍙e紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 瀵煎嚭鍙栨按鍙e垪琛�
+ *
+ * @param response
+ * @param vo
+ */
+ @SneakyThrows(IOException.class)
+ @GetMapping(value = "exportIntakes")
+ @SsoAop()
+ public void exportIntakes(HttpServletResponse response, QueryVo vo) {
+ List<VoIntake> intakeList = intakeSv.exportIntakes(vo);
+
+ ExcelUtil.setExcelRespProp(response, "鍙栨按鍙e垪琛�" + LocalDate.now());
+ EasyExcel.write(response.getOutputStream(), VoIntake.class)
+ .registerWriteHandler(new CellWriteHandler("鍙栨按鍙e垪琛�"))
+ .sheet("鍙栨按鍙�")
+ .doWrite(intakeList);
+ }
+
+ /**
+ * 瀵煎叆鍙栨按鍙e垪琛�
+ *
+ * @param file
+ */
+ @SneakyThrows
+ @PostMapping(value = "importIntakes")
+ @ResponseBody
+ public BaseResponse<Boolean> importIntakes(@RequestPart("file") MultipartFile file) {
+ List<VoIntake> memberList = EasyExcel.read(file.getInputStream())
+ .head(VoIntake.class)
+ .sheet()
+ .doReadSync();
+ return BaseResponseUtils.buildSuccess(memberList);
+ }
+
+ /**
+ * 璁剧疆excel涓嬭浇鍝嶅簲澶村睘鎬�
+ */
+ private void setExcelRespProp(HttpServletResponse response, String rawFileName) throws UnsupportedEncodingException {
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ response.setCharacterEncoding("utf-8");
+ String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20");
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
+ }
+
+ /**
+ * 姝ゅ姛鑳藉凡缍撶Щ妞嶅埌remote妯″鐨凪onitroCtrl涓�
+ * 鑾峰彇鍙栨按鍙e垪琛紙鍦ㄧ嚎鍜屼笉鍦ㄧ嚎锛�
+ * @param qo
+ * @return
+ @GetMapping(path = "all_intakes")
+ @SsoAop()
+ public BaseResponse<QueryResultVo<List<VoOnLineIntake>>> getAllIntakes(OnLineIntakesQO qo) {
+ try {
+ QueryResultVo<List<VoOnLineIntake>> res = intakeSv.selectOnLineIntakes(qo);
+ return BaseResponseUtils.buildSuccess(res);
+ } catch (Exception e) {
+ log.error("鏌ヨ鍙栨按鍙e紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+ */
+ /**
+ * 鏍规嵁鎿嶄綔鍛樿幏鍙栧父鐢ㄥ彇姘村彛锛堝湪绾垮拰涓嶅湪绾匡級
+ *
+ * @param operator
+ * @return
+ */
+ @GetMapping(path = "used_intakes")
+ @SsoAop()
+ public BaseResponse<List<VoOnLineIntake>> getUsedIntakes(Long operator) {
+ try {
+ List<VoOnLineIntake> res = intakeSv.getUsedIntakes(operator);
+ return BaseResponseUtils.buildSuccess(res);
+ } catch (Exception e) {
+ log.error("鏌ヨ鍙栨按鍙e紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+ /**
+ * 鑾峰彇鏈粦瀹氬埌杞亴缁勭殑鍙栨按鍙e垪琛�
+ * @return
+ */
+ @GetMapping(path = "getFreeIntakes")
+ @SsoAop()
+ public BaseResponse<List<VoIntakeSimple>> getFreeIntakes(QoIntake qo) {
+ try {
+ List<VoIntakeSimple> res = intakeSv.getFreeIntakes(qo);
+ return BaseResponseUtils.buildSuccess(res);
+ } catch (Exception e) {
+ log.error("鏌ヨ鍙栨按鍙e紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+}
--
Gitblit v1.8.0