From 3e43f5f1c45d92344d770868c7051b03a3ab4a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B3=BD=E8=85=BE?= <1178634255@qq.com> Date: Fri, 25 Aug 2023 15:52:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86-=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E8=B5=84=E8=B4=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inv/DeviceAssetCertController.java | 74 +++++++++++++++++-- .../purchase/SupCertController.java | 1 - .../api/dao/inv/DeviceAssetCertMapper.java | 12 ++- .../api/entity/inv/DeviceAssetCertEntity.java | 18 +++-- .../api/handler/GlobalExceptionHandler.java | 5 +- .../api/req/inv/PostDeviceCertRequest.java | 11 +++ .../req/system/DeleteDeviceFileRequest.java | 11 +++ .../service/inv/DeviceAssetCertService.java | 21 +++++- .../inv/impl/DeviceAssetCertServiceImpl.java | 17 +++++ src/main/resources/application-hzt.yml | 60 +++++++++++++++ .../mapper/inv/DeviceAssetCertMapper.xml | 32 +++++++- 11 files changed, 239 insertions(+), 23 deletions(-) create mode 100644 src/main/java/com/glxp/api/req/inv/PostDeviceCertRequest.java create mode 100644 src/main/java/com/glxp/api/req/system/DeleteDeviceFileRequest.java create mode 100644 src/main/resources/application-hzt.yml diff --git a/src/main/java/com/glxp/api/controller/inv/DeviceAssetCertController.java b/src/main/java/com/glxp/api/controller/inv/DeviceAssetCertController.java index dae7c9d4..b0b0baa7 100644 --- a/src/main/java/com/glxp/api/controller/inv/DeviceAssetCertController.java +++ b/src/main/java/com/glxp/api/controller/inv/DeviceAssetCertController.java @@ -1,24 +1,35 @@ package com.glxp.api.controller.inv; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.IdUtil; import com.github.pagehelper.PageInfo; import com.glxp.api.annotation.AuthRuleAnnotation; -import com.glxp.api.common.enums.ResultEnum; +import com.glxp.api.annotation.Log; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.constant.BusinessType; +import com.glxp.api.constant.FileConstant; import com.glxp.api.controller.BaseController; import com.glxp.api.entity.inv.DeviceAssetCertEntity; -import com.glxp.api.entity.purchase.SupCertEntity; import com.glxp.api.req.inv.FilterInvCertRequest; -import com.glxp.api.req.purchase.FilterSupCertRequest; +import com.glxp.api.req.inv.PostDeviceCertRequest; +import com.glxp.api.req.system.DeleteDeviceFileRequest; import com.glxp.api.res.PageSimpleResponse; import com.glxp.api.service.inv.DeviceAssetCertService; -import com.glxp.api.service.purchase.SupCertService; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.io.File; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.List; /** @@ -27,12 +38,14 @@ import java.util.List; @Slf4j @RestController public class DeviceAssetCertController extends BaseController { + @Value("${file_path}") + private String filePath; @Resource private DeviceAssetCertService deviceAssetCertService; -// @AuthRuleAnnotation("") + + @AuthRuleAnnotation("") @GetMapping("/inv/device/cert/filter") public BaseResponse filterDeviceCert(FilterInvCertRequest filterInvCertRequest) { - List deviceAssetCertEntityList = deviceAssetCertService.filterDeviceCert(filterInvCertRequest); PageInfo pageInfo; @@ -43,7 +56,56 @@ public class DeviceAssetCertController extends BaseController { return ResultVOUtils.success(pageSimpleResponse); } + @AuthRuleAnnotation("") + @PostMapping("/inv/info/insertDeviceCert") + @Log(title = "资质证书", businessType = BusinessType.INSERT) + public BaseResponse insertDeviceCert(@RequestBody DeviceAssetCertEntity deviceAssetCertEntity) { + deviceAssetCertEntity.setCreateTime(LocalDate.now()); + deviceAssetCertEntity.setUpdateTime(LocalDate.now()); + deviceAssetCertEntity.setStatus(0); + deviceAssetCertEntity.setId(IdUtil.getSnowflakeNextId()); + boolean b = deviceAssetCertService.insertDeviceCert(deviceAssetCertEntity); + return ResultVOUtils.success("成功"); + } + + @AuthRuleAnnotation("") + @PostMapping("/inv/info/deleteDeviceCert") + public BaseResponse deleteDeviceCert(@RequestBody DeleteDeviceFileRequest deleteDeviceFileRequest, BindingResult bindingResult) { + boolean b = deviceAssetCertService.deleteById(deleteDeviceFileRequest.getId()); + String URL = filePath + FileConstant.COMMON_FILE_PATH + deleteDeviceFileRequest.getFilePath(); + File file = new File(URL); + if (file.exists() && file.isFile()) { + file.delete(); + } + return ResultVOUtils.success("成功"); + } + + @AuthRuleAnnotation("") + @PostMapping("/inv/info/updateDeviceCert") + @Log(title = "资质证书", businessType = BusinessType.UPDATE) + public BaseResponse updateDeviceCert(@RequestBody PostDeviceCertRequest postDeviceCertRequest) { + DeviceAssetCertEntity deviceAssetCertEntity = new DeviceAssetCertEntity(); + BeanUtil.copyProperties(postDeviceCertRequest, deviceAssetCertEntity); + LocalDateTime localDateTime1 = postDeviceCertRequest.getVailDate().atStartOfDay(); + LocalDateTime localDateTime2= postDeviceCertRequest.getExpireDate().atStartOfDay(); + Instant instant = localDateTime1.toInstant(ZoneOffset.UTC); + Instant instant2 = localDateTime2.toInstant(ZoneOffset.UTC); + long milliseconds = instant.toEpochMilli(); + long milliseconds2 = instant2.toEpochMilli(); + if (postDeviceCertRequest.getVailDate() != null && postDeviceCertRequest.getExpireDate() != null) { + if (milliseconds > milliseconds2) { + return ResultVOUtils.error(999, "生效期不能小于失效期!"); + } + } + boolean b = deviceAssetCertService.updateDeviceCert(deviceAssetCertEntity); + if (b){ + return ResultVOUtils.success("修改成功"); + }else { + return ResultVOUtils.error(999,"修改失败!"); + } + + } } diff --git a/src/main/java/com/glxp/api/controller/purchase/SupCertController.java b/src/main/java/com/glxp/api/controller/purchase/SupCertController.java index b2d0fa0b..34f0e16f 100644 --- a/src/main/java/com/glxp/api/controller/purchase/SupCertController.java +++ b/src/main/java/com/glxp/api/controller/purchase/SupCertController.java @@ -32,7 +32,6 @@ import com.glxp.api.service.purchase.SupProductService; import com.glxp.api.service.system.SystemPDFModuleService; import com.glxp.api.service.system.SystemPDFTemplateService; import com.glxp.api.util.JasperUtils; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.GetMapping; diff --git a/src/main/java/com/glxp/api/dao/inv/DeviceAssetCertMapper.java b/src/main/java/com/glxp/api/dao/inv/DeviceAssetCertMapper.java index e42b596e..26041ed7 100644 --- a/src/main/java/com/glxp/api/dao/inv/DeviceAssetCertMapper.java +++ b/src/main/java/com/glxp/api/dao/inv/DeviceAssetCertMapper.java @@ -2,9 +2,7 @@ package com.glxp.api.dao.inv; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.glxp.api.entity.inv.DeviceAssetCertEntity; -import com.glxp.api.entity.purchase.SupCertEntity; import com.glxp.api.req.inv.FilterInvCertRequest; -import com.glxp.api.req.purchase.FilterSupCertRequest; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -14,4 +12,14 @@ public interface DeviceAssetCertMapper extends BaseMapper List filterCompanyCert(FilterInvCertRequest filterInvCertRequest); + boolean deleteById(String id); + + + + boolean updateDeviceCert(DeviceAssetCertEntity deviceAssetCertEntity); + + + + + } diff --git a/src/main/java/com/glxp/api/entity/inv/DeviceAssetCertEntity.java b/src/main/java/com/glxp/api/entity/inv/DeviceAssetCertEntity.java index 54f0681a..47f48e2c 100644 --- a/src/main/java/com/glxp/api/entity/inv/DeviceAssetCertEntity.java +++ b/src/main/java/com/glxp/api/entity/inv/DeviceAssetCertEntity.java @@ -4,11 +4,11 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; import java.io.Serializable; -import java.util.Date; - -import lombok.Data; +import java.time.LocalDate; @Data @TableName(value = "device_asset_cert") @@ -47,13 +47,15 @@ public class DeviceAssetCertEntity implements Serializable { * 生效期 */ @TableField(value = "vailDate") - private Date vailDate; + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate vailDate; /** * 失效期 */ @TableField(value = "expireDate") - private Date expireDate; + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate expireDate; /** * 证书状态 @@ -83,7 +85,8 @@ public class DeviceAssetCertEntity implements Serializable { * 创建时间 */ @TableField(value = "createTime") - private Date createTime; + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate createTime; /** * 更新人 @@ -95,7 +98,8 @@ public class DeviceAssetCertEntity implements Serializable { * 更新时间 */ @TableField(value = "updateTime") - private Date updateTime; + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate updateTime; private static final long serialVersionUID = 1L; } diff --git a/src/main/java/com/glxp/api/handler/GlobalExceptionHandler.java b/src/main/java/com/glxp/api/handler/GlobalExceptionHandler.java index 5b521317..c56ab31b 100644 --- a/src/main/java/com/glxp/api/handler/GlobalExceptionHandler.java +++ b/src/main/java/com/glxp/api/handler/GlobalExceptionHandler.java @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; @RestControllerAdvice @Slf4j public class GlobalExceptionHandler { - + // 拦截API异常 @ExceptionHandler(value = JsonException.class) public BaseResponse handlerJsonException(JsonException e) { @@ -25,9 +25,10 @@ public class GlobalExceptionHandler { // 拦截API异常 @ExceptionHandler(value = RuntimeException.class) public BaseResponse handlerRuntimeException(RuntimeException e) { + e.printStackTrace(); log.error(e.getMessage(), e); // 返回对应的错误信息 return ResultVOUtils.error(ResultEnum.NOT_NETWORK); } - + } diff --git a/src/main/java/com/glxp/api/req/inv/PostDeviceCertRequest.java b/src/main/java/com/glxp/api/req/inv/PostDeviceCertRequest.java new file mode 100644 index 00000000..8c5435c4 --- /dev/null +++ b/src/main/java/com/glxp/api/req/inv/PostDeviceCertRequest.java @@ -0,0 +1,11 @@ +package com.glxp.api.req.inv; + +import com.glxp.api.entity.inv.DeviceAssetCertEntity; +import lombok.Data; + +@Data +public class PostDeviceCertRequest extends DeviceAssetCertEntity { + + + private int repeatUpload; +} diff --git a/src/main/java/com/glxp/api/req/system/DeleteDeviceFileRequest.java b/src/main/java/com/glxp/api/req/system/DeleteDeviceFileRequest.java new file mode 100644 index 00000000..65cd374b --- /dev/null +++ b/src/main/java/com/glxp/api/req/system/DeleteDeviceFileRequest.java @@ -0,0 +1,11 @@ +package com.glxp.api.req.system; + +import lombok.Data; + +@Data +public class DeleteDeviceFileRequest { + + String id; + String filePath; + String filePath2; +} diff --git a/src/main/java/com/glxp/api/service/inv/DeviceAssetCertService.java b/src/main/java/com/glxp/api/service/inv/DeviceAssetCertService.java index 771256ce..055797f9 100644 --- a/src/main/java/com/glxp/api/service/inv/DeviceAssetCertService.java +++ b/src/main/java/com/glxp/api/service/inv/DeviceAssetCertService.java @@ -1,10 +1,9 @@ package com.glxp.api.service.inv; import com.baomidou.mybatisplus.extension.service.IService; +import com.glxp.api.entity.inv.DeviceAssetCertEntity; import com.glxp.api.req.inv.FilterInvCertRequest; import org.springframework.stereotype.Service; -import com.glxp.api.entity.inv.DeviceAssetCertEntity; - import java.util.List; @@ -12,6 +11,24 @@ import java.util.List; public interface DeviceAssetCertService extends IService { List filterDeviceCert(FilterInvCertRequest filterInvCertRequest); + boolean insertDeviceCert(DeviceAssetCertEntity deviceAssetCertEntity); + + boolean deleteById(String id); + + boolean updateDeviceCert(DeviceAssetCertEntity deviceAssetCertEntity); + + + + + + + + + + + + + } diff --git a/src/main/java/com/glxp/api/service/inv/impl/DeviceAssetCertServiceImpl.java b/src/main/java/com/glxp/api/service/inv/impl/DeviceAssetCertServiceImpl.java index a7c000c1..37d53e0c 100644 --- a/src/main/java/com/glxp/api/service/inv/impl/DeviceAssetCertServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inv/impl/DeviceAssetCertServiceImpl.java @@ -34,4 +34,21 @@ public class DeviceAssetCertServiceImpl extends ServiceImpl 0 ? true : false; + } + + @Override + public boolean deleteById(String id) { + return deviceAssetCertMapper.deleteById(id); + } + + @Override + public boolean updateDeviceCert(DeviceAssetCertEntity deviceAssetCertEntity) { + return deviceAssetCertMapper.updateDeviceCert(deviceAssetCertEntity); + } + + + } diff --git a/src/main/resources/application-hzt.yml b/src/main/resources/application-hzt.yml new file mode 100644 index 00000000..c2992225 --- /dev/null +++ b/src/main/resources/application-hzt.yml @@ -0,0 +1,60 @@ +server: + port: 9991 + +spring: + datasource: + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + jdbc-url: jdbc:p6spy:mysql://192.168.0.66:3364/udi_wms_pt?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true + username: root + password: Glxp@6066 + hikari: + connection-timeout: 60000 + maximum-pool-size: 20 + minimum-idle: 10 + + + redis: + database: 8 + host: 127.0.0.1 + port: 6379 + # password: 123456 + timeout: 300 + jedis: + pool: + max-active: 8 + max-wait: -1 + max-idle: 8 + min-idle: 0 + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + servlet: + multipart: + max-file-size: 500MB + max-request-size: 500MB + +ok: + http: + connect-timeout: 3000 + read-timeout: 3000 + write-timeout: 3000 + max-idle-connections: 200 + keep-alive-duration: 300 + + +logging: + level: + com.glxp.api.dao: debug + +file_path: E:/udi/udiwms/udiwmsfile/ +file_lpath: /udiwms/image/register/file/getImage +file_url: http://127.0.0.1:9991 +UDI_KEY: 6b137c66-6286-46c6-8efa-c2f5dd9237df +UDI_SERVER_URL: https://www.udims.com/UDI_DL_Server_test +SPMS_KEY: lCOdWCBKS6Kw45wdnnqUTELXyuSKnXEs + +back_file_path: E:/share/udisps/back/ +SPMS_WEBSOCKET_TOKEN: 07rKFDFkQvBkbxgc7aUBlONo4gWNdx8b +API_KEY: 1101 +API_SECRET: zBITspLNvuoEd4FaamlSoqxRHmNsmQ6L +WEB_TITLE: 平潭协和医院 diff --git a/src/main/resources/mybatis/mapper/inv/DeviceAssetCertMapper.xml b/src/main/resources/mybatis/mapper/inv/DeviceAssetCertMapper.xml index 68731380..84984329 100644 --- a/src/main/resources/mybatis/mapper/inv/DeviceAssetCertMapper.xml +++ b/src/main/resources/mybatis/mapper/inv/DeviceAssetCertMapper.xml @@ -29,9 +29,10 @@ resultType="com.glxp.api.entity.inv.DeviceAssetCertEntity"> select * from device_asset_cert - - and devCodeFk = #{devCodeFk} - + devCodeFk = #{devCodeFk} + + + and name = #{name} @@ -50,4 +51,29 @@ ORDER BY id DESC + + DELETE + FROM device_asset_cert + WHERE id = #{id} + + + + UPDATE device_asset_cert + + name=#{name}, + devCodeFk=#{devCodeFk}, + filePath=#{filePath}, + remark=#{remark}, + vailDate=#{vailDate}, + expireDate=#{expireDate}, + `type`=#{type}, + `code`=#{code}, + `status`=#{status}, + + + WHERE id = #{id} + + + +