From e706b848e0a32628e869b312bb5d1557d0030dcc Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 10 七月 2024 18:07:31 +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 | 153 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 105 insertions(+), 48 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
index fd25e3e..455015f 100644
--- 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
@@ -9,7 +9,10 @@
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrGlobal.pojoPr.PrIntake;
import com.dy.pipIrrGlobal.voPr.VoIntake;
+import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
import com.dy.pipIrrGlobal.voSe.VoActiveCard;
+import com.dy.pipIrrProject.intake.qo.OnLineIntakesQO;
+import com.dy.pipIrrProject.result.ProjectResultCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
@@ -32,10 +35,7 @@
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.time.format.DateTimeFormatter;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
+import java.util.*;
/**
* @author WuZeYu
@@ -47,13 +47,14 @@
@Slf4j
@Tag(name = "鍙栨按鍙g鐞�", description = "鍙栨按鍙f搷浣�")
@RestController
-@RequestMapping(path="intake")
+@RequestMapping(path = "intake")
@RequiredArgsConstructor
public class IntakeCtrl {
private final IntakeSv intakeSv;
/**
* 瀹㈡埛绔姹傚緱鍒版墍鏈夊彇姘村彛鍚嶅瓧
+ *
* @return 鎵�鏈夊彇姘村彛鍚嶅瓧
*/
@Operation(summary = "鑾峰緱鍏ㄩ儴鍙栨按鍙�", description = "杩斿洖鍏ㄩ儴鍙栨按鍙f暟鎹�")
@@ -67,18 +68,23 @@
})
@GetMapping(path = "all")
@SsoAop()
- public BaseResponse<QueryResultVo<List<PrIntake>>> all(){
+ public BaseResponse<QueryResultVo<List<PrIntake>>> all() {
try {
QueryResultVo<List<PrIntake>> res = this.intakeSv.selectAll();
- return BaseResponseUtils.buildSuccess(res);
+ if (res == null) {
+ return BaseResponseUtils.buildFail(ProjectResultCode.NO_INTAKES.getMessage());
+ } else {
+ return BaseResponseUtils.buildSuccess(res);
+ }
} catch (Exception e) {
log.error("鏌ヨ鍙栨按鍙e紓甯�", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
+ return BaseResponseUtils.buildException(e.getMessage());
}
}
/**
* 寰楀埌涓�涓彇姘村彛鏁版嵁
+ *
* @return 涓�涓彇姘村彛鏁版嵁
*/
@Operation(summary = "涓�涓彇姘村彛", description = "寰楀埌涓�涓彇姘村彛鏁版嵁")
@@ -92,8 +98,12 @@
})
@GetMapping(path = "one/{id}")
@SsoAop()
- public BaseResponse<PrIntake> one(@PathVariable("id") Long id){
- return BaseResponseUtils.buildSuccess(this.intakeSv.selectById(id));
+ public BaseResponse<PrIntake> one(@PathVariable("id") Long id) {
+ if (this.intakeSv.selectById(id) == null) {
+ return BaseResponseUtils.buildFail(ProjectResultCode.NO_INTAKES.getMessage());
+ } else {
+ return BaseResponseUtils.buildSuccess(this.intakeSv.selectById(id));
+ }
}
@Operation(summary = "鑾峰緱涓�椤靛彇姘村彛璁板綍", description = "杩斿洖涓�椤靛彇姘村彛鏁版嵁")
@@ -105,18 +115,18 @@
schema = @Schema(implementation = VoActiveCard.class))}
)
})
- @GetMapping(path = "getIntakes", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @GetMapping(path = "getIntakes")
@SsoAop()
- public BaseResponse<QueryResultVo<List<VoIntake>>> getIntakes(@RequestBody @Parameter(description = "鏌ヨform琛ㄥ崟json鏁版嵁", required = true) QueryVo vo){
+ public BaseResponse<QueryResultVo<List<VoIntake>>> getIntakes(QueryVo vo) {
try {
QueryResultVo<List<VoIntake>> res = intakeSv.getIntakes(vo);
- if(res == null) {
- return BaseResponseUtils.buildFail("鏌ヨ澶辫触");
+ if (res == null) {
+ return BaseResponseUtils.buildFail(ProjectResultCode.NO_INTAKES.getMessage());
}
return BaseResponseUtils.buildSuccess(res);
} catch (Exception e) {
log.error("鑾峰彇鍙栨按鍙h褰曞紓甯�", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
+ return BaseResponseUtils.buildException(e.getMessage());
}
}
@@ -132,23 +142,27 @@
@PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE)
@Transactional(rollbackFor = Exception.class)
@SsoAop()
- public BaseResponse<Boolean> add(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid PrIntake po, @Parameter(hidden = true) BindingResult bindingResult){
+ 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()){
+ if (bindingResult != null && bindingResult.hasErrors()) {
return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
-
- Date operateTime = new Date();
- po.setOperateDt(operateTime);
- Integer rec = Optional.ofNullable(intakeSv.addIntake(po)).orElse(0);
- if(rec == 0) {
- return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ List<Long> ids = intakeSv.getIntakeIdsByName(po.getName());
+ if (ids.size() > 0) {
+ return BaseResponseUtils.buildFail(ProjectResultCode.INTAKE_NAME_EXIST.getMessage());
}
- return BaseResponseUtils.buildSuccess(true) ;
+ po.setOperateDt(new Date());
+ po.setDeleted((byte)0);
+ Integer rec = Optional.ofNullable(intakeSv.addIntake(po)).orElse(0);
+ if (rec == 0) {
+ return BaseResponseUtils.buildFail(ProjectResultCode.ADD_INTAKE_FAIL.getMessage());
+ }
+ return BaseResponseUtils.buildSuccess(true);
}
/**
* 缂栬緫淇敼鍙栨按鍙�
+ *
* @param po 淇濆瓨鍙栨按鍙orm琛ㄥ崟瀵硅薄
* @return 鏄惁鎴愬姛
*/
@@ -163,29 +177,33 @@
})
@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()){
+ 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.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
+ List<Long> ids = intakeSv.getIntakeIdByNameExcludeId(po.getId(), po.getName());
+ if (ids.size() > 0){
+ return BaseResponseUtils.buildFail(ProjectResultCode.INTAKE_NAME_EXIST.getMessage());
+ }
int count;
- Date operateTime = new Date();
- po.setOperateDt(operateTime);
+ po.setOperateDt( new Date());
try {
count = this.intakeSv.update(po);
} catch (Exception e) {
- log.error("淇濆瓨鍒嗘按鍙e紓甯�", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
+ log.error("淇濆瓨鍙栨按鍙e紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
}
- if(count <= 0){
- return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
- }else{
- return BaseResponseUtils.buildSuccess(true) ;
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail(ProjectResultCode.UPDATE_INTAKE.getMessage());
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
}
}
/**
* 鍒犻櫎鍙栨按鍙�
- * @param id 鍙栨按鍙D
+ *
+ * @param map 鍙栨按鍙D
* @return 鏄惁鎴愬姛
*/
@Operation(summary = "鍒犻櫎鍒嗘按鍙�", description = "鎻愪氦鍙栨按鍙D锛岃繘琛岄�昏緫鍒犻櫎")
@@ -197,28 +215,32 @@
schema = @Schema(implementation = Boolean.class))}
)
})
- @GetMapping(path = "delete/{id}")
+ @PostMapping(path = "delete")
@SsoAop()
- public BaseResponse<Boolean> delete(@PathVariable("id") Long id){
- if(id == null){
- return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ;
+ public BaseResponse<Boolean> delete(@RequestBody Map map) {
+ if (map == null || map.size() <= 0) {
+ return BaseResponseUtils.buildFail(ProjectResultCode.PLEASE_INPUT_INTAKE_ID.getMessage());
}
- int count;
+ Long id = Long.parseLong(map.get("id").toString());
try {
- count = this.intakeSv.delete(id);
+ //鍙栨按鍙D
+ Integer recordCount = Optional.ofNullable(intakeSv.delete(id)).orElse(0);
+ if (recordCount == 0) {
+ return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_INTAKE_FAIL.getMessage());
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
} catch (Exception e) {
log.error("淇濆瓨鍒嗘按鍙e紓甯�", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
+ return BaseResponseUtils.buildException(e.getMessage());
}
- if(count <= 0){
- return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
- }else{
- return BaseResponseUtils.buildSuccess(true) ;
- }
+
+
}
/**
* 瀵煎嚭鍙栨按鍙e垪琛�
+ *
* @param response
* @param vo
*/
@@ -238,6 +260,7 @@
/**
* 瀵煎叆鍙栨按鍙e垪琛�
+ *
* @param file
*/
@SneakyThrows
@@ -248,7 +271,7 @@
.head(VoIntake.class)
.sheet()
.doReadSync();
- return BaseResponseUtils.buildSuccess(memberList) ;
+ return BaseResponseUtils.buildSuccess(memberList);
}
/**
@@ -260,4 +283,38 @@
String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
}
+
+ /**
+ * 鑾峰彇鍙栨按鍙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());
+ }
+ }
}
--
Gitblit v1.8.0