From bc230a4679ee851d5bd9cab83ad6316e483a5764 Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期一, 11 十二月 2023 15:21:36 +0800 Subject: [PATCH] 2023-12-11 朱宝民 IC卡14个接口完成,全部改为长主键 --- pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/unlock/UnlockCtrl.java | 92 ++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 88 insertions(+), 4 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/unlock/UnlockCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/unlock/UnlockCtrl.java index f93ce4b..c4684c6 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/unlock/UnlockCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/unlock/UnlockCtrl.java @@ -5,7 +5,11 @@ import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.common.webUtil.ResultCodeMsg; +import com.dy.pipIrrGlobal.pojoSe.SeClientCard; +import com.dy.pipIrrGlobal.pojoSe.SeUnlock; import com.dy.pipIrrGlobal.voSe.VoUnlock; +import com.dy.pipIrrSell.clientCard.ClientCardSv; +import com.dy.pipIrrSell.clientCard.LastOperateENUM; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; @@ -13,15 +17,19 @@ 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.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; +import java.time.format.DateTimeFormatter; +import java.util.Date; import java.util.List; +import java.util.Objects; +import java.util.Optional; /** * @author ZhuBaoMin @@ -37,6 +45,7 @@ @RequiredArgsConstructor public class UnlockCtrl { private final UnlockSv unlockSv; + private final ClientCardSv clientCardSv; @Operation(summary = "鑾峰緱涓�椤佃В閿佽褰�", description = "杩斿洖涓�椤佃В閿佹暟鎹�") @ApiResponses(value = { @@ -58,4 +67,79 @@ return BaseResponseUtils.buildException(e.getMessage()) ; } } + + @Operation(summary = "娣诲姞瑙i攣璁板綍", description = "娣诲姞瑙i攣璁板綍") + @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("-1")//@SsoAop(power = "-1") + public BaseResponse<Boolean> add(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid DtoUnlock po, @Parameter(hidden = true) BindingResult bindingResult){ + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + /** + * cardId 姘村崱缂栧彿锛堥潪浼犲叆鍙傛暟锛岀敱cardAddr鍙嶆煡锛� + * cardAddr 姘村崱鍦板潃 + * clientId 鍐滄埛缂栧彿 + * money 浣欓 + * remarks 澶囨敞 + * operator 鎿嶄綔浜虹紪鍙� + * unlockTime 瑙i攣鏃堕棿 + */ + Long cardId = 0L; + String cardAddr = po.getCardAddr(); + Long clientId = po.getClientId(); + Float money = po.getMoney(); + String remarks = po.getRemarks(); + Long operator = po.getOperator(); + Date unlockTime = new Date(); + + /** + * 渚濇嵁姘村崱鍦板潃鑾峰彇姘村崱缂栧彿锛堜富閿級 + */ + cardId = Optional.ofNullable(clientCardSv.getCardIdByAddr(cardAddr)).orElse(0L); + if(cardId == 0) { + return BaseResponseUtils.buildFail("鍗″彿閿欒锛岃鍗′笉瀛樺湪"); + } + + /** + * 淇敼鍐滄埛鍗′俊鎭細 + * 鎸傚け鏃堕棿 + * 鏈�鍚庢搷浣滅被鍨�-4 + */ + SeClientCard seClientCard = new SeClientCard(); + seClientCard.setId(cardId); + seClientCard.setUnlockdt(unlockTime); + seClientCard.setLastoper(LastOperateENUM.UNLOCK.getCode()); + Integer rec_updateClientCard = Optional.ofNullable(clientCardSv.UpdateClientCard(seClientCard)).orElse(0); + if(rec_updateClientCard == 0) { + return BaseResponseUtils.buildFail("瑙i攣澶辫触-鍐滄埛鍗¤В閿佸紓甯�"); + } + + /** + * 娣诲姞瑙i攣璁板綍 + */ + SeUnlock seUnlock = new SeUnlock(); + seUnlock.setCardid(cardId); + seUnlock.setClientid(clientId); + seUnlock.setMoney(money); + seUnlock.setRemarks(remarks); + seUnlock.setOperator(operator); + seUnlock.setOperatedt(unlockTime); + Long rec = Optional.ofNullable(unlockSv.add(seUnlock)).orElse(0L); + if(rec == 0) { + return BaseResponseUtils.buildFail("瑙i攣澶辫触-瑙i攣璁板綍鍐欏叆寮傚父"); + } + + return BaseResponseUtils.buildSuccess(true) ; + } } -- Gitblit v1.8.0