@@ -1,8 +1,14 @@ | |||
package cn.com.taiji.core.repo.jpa.invw; | |||
import java.util.List; | |||
import org.springframework.data.jpa.repository.Query; | |||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | |||
import cn.com.taiji.core.entity.invw.InvwRebackApplyDetails; | |||
public interface InvwRebackApplyDetailsRepo extends AbstractJpaRepo<InvwRebackApplyDetails, String>{ | |||
@Query(value = "from InvwRebackApplyDetails where applyNo = ?1") | |||
List<InvwRebackApplyDetails> listByApplyNo(String applyNo); | |||
} |
@@ -2,7 +2,14 @@ package cn.com.taiji.core.repo.jpa.invw; | |||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | |||
import cn.com.taiji.core.entity.invw.InvwRebackApply; | |||
import org.springframework.data.jpa.repository.Query; | |||
public interface InvwRebackApplyRepo extends AbstractJpaRepo<InvwRebackApply, String>{ | |||
@Query( | |||
nativeQuery = true, | |||
value = "select * from (select * from INVW_REBACK_APPLY where 1=1 order by id desc) where rownum <= 1" | |||
) | |||
InvwRebackApply getMaxId(); | |||
} |
@@ -9,8 +9,8 @@ import java.util.List; | |||
public interface AccountInfoRepo extends AbstractJpaRepo<AccountInfo, String> { | |||
@Query("FROM AccountInfo WHERE account=?1") | |||
AccountInfo findByAccount(String account); | |||
// @Query("FROM AccountInfo WHERE account=?1") | |||
// AccountInfo findByAccount(String account); | |||
@Query("FROM AccountInfo WHERE openId=?1") | |||
AccountInfo findByOpenId(String openId); |
@@ -2,6 +2,8 @@ package cn.com.taiji.core.repo.request.invw; | |||
import cn.com.taiji.common.pub.dao.HqlBuilder; | |||
import cn.com.taiji.common.repo.request.jpa.JpaDateTimePageableDataRequest; | |||
import cn.com.taiji.core.entity.dict.invw.InvApplyStatus; | |||
import cn.com.taiji.core.entity.dict.invw.InventoryType; | |||
import cn.com.taiji.core.entity.invw.InvwRebackApply; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
@@ -10,8 +12,10 @@ import lombok.Setter; | |||
@Setter | |||
public class InvwRebackApplyPageRequest extends JpaDateTimePageableDataRequest<InvwRebackApply>{ | |||
private String rebackStoreCode; | |||
private String receiveStoreCode; | |||
private InventoryType inventoryType; | |||
private InvApplyStatus applyStatus; | |||
public InvwRebackApplyPageRequest() { | |||
this.orderBy="id"; | |||
@@ -21,7 +25,10 @@ public class InvwRebackApplyPageRequest extends JpaDateTimePageableDataRequest<I | |||
@Override | |||
public HqlBuilder toSelectHql(){ | |||
HqlBuilder hql = new HqlBuilder("from InvwRebackApply where 1=1 "); | |||
hql.append(" and rebackStoreCode =: rebackStoreCode", rebackStoreCode); | |||
hql.append(" and receiveStoreCode =: receiveStoreCode", receiveStoreCode); | |||
hql.append(" and inventoryType =: inventoryType", inventoryType); | |||
hql.append(" and applyStatus =: applyStatus", applyStatus); | |||
return hql; | |||
} | |||
@@ -0,0 +1,70 @@ | |||
package cn.com.taiji.invw.api.reback; | |||
import javax.validation.Valid; | |||
import cn.com.taiji.invw.dto.reback.*; | |||
import cn.com.taiji.invw.manager.reback.InvwRebackManager; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.common.web.ApiResponse; | |||
import cn.com.taiji.invw.api.MyValidController; | |||
import cn.com.taiji.invw.dto.warehouse.*; | |||
import cn.com.taiji.invw.manager.warehouse.InvwWarehouseManager; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
@Api(tags = {"007-回收管理"}) | |||
@RestController | |||
@RequestMapping("/api/reback") | |||
public class InvwRebackController extends MyValidController { | |||
@Autowired | |||
private InvwRebackManager manager; | |||
@ApiOperation(value = "01-分页查询") | |||
@PostMapping("/page") | |||
public ApiResponse<Pagination> page(@Valid @RequestBody InvwRebackApplyPageRequestDTO req) { | |||
return ApiResponse.of(manager.page(req)); | |||
} | |||
@ApiOperation(value = "02-新增申请") | |||
@PostMapping("/add") | |||
public ApiResponse add(@Valid @RequestBody InvwRebackApplyRequestDTO req) throws ManagerException { | |||
manager.add(req); | |||
return ApiResponse.success().setMessage("操作成功"); | |||
} | |||
@ApiOperation(value = "03-申请修改") | |||
@PostMapping("/modify") | |||
public ApiResponse modify(@Valid @RequestBody InvwRebackModifyRequestDTO req) throws ManagerException { | |||
manager.modify(req); | |||
return ApiResponse.success().setMessage("操作成功"); | |||
} | |||
@ApiOperation(value = "04-申请详情") | |||
@PostMapping("/view") | |||
public ApiResponse<InvwRebackApplyViewResponseDTO> view(@Valid @RequestBody InvwRebackApplyViewRequestDTO req) throws ManagerException { | |||
InvwRebackApplyViewResponseDTO response = manager.view(req); | |||
return ApiResponse.of(response); | |||
} | |||
@ApiOperation(value = "05-申请取消") | |||
@PostMapping("/cancel") | |||
public ApiResponse cancel(@Valid @RequestBody InvwRebackApplyCancelRequestDTO req) throws ManagerException { | |||
manager.cancel(req); | |||
return ApiResponse.success().setMessage("操作成功"); | |||
} | |||
@ApiOperation(value = "06-确认收货") | |||
@PostMapping("/confirmReceipt") | |||
public ApiResponse confirmReceipt(@Valid @RequestBody InvwRebackApplyConfirmReceiptRequestDTO req) throws ManagerException { | |||
manager.confirm(req); | |||
return ApiResponse.success().setMessage("操作成功"); | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
package cn.com.taiji.invw.dto.reback; | |||
import javax.validation.constraints.NotBlank; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
@ApiModel(description = "回收取消") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwRebackApplyCancelRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "id", required = true) | |||
@NotBlank(message = "id不能为空") | |||
private String id; | |||
} |
@@ -0,0 +1,22 @@ | |||
package cn.com.taiji.invw.dto.reback; | |||
import javax.validation.constraints.NotBlank; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
@ApiModel(description = "回收取消") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwRebackApplyConfirmReceiptRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "id", required = true) | |||
@NotBlank(message = "id不能为空") | |||
private String id; | |||
} |
@@ -0,0 +1,26 @@ | |||
package cn.com.taiji.invw.dto.reback; | |||
import javax.validation.constraints.NotBlank; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
@ApiModel(description = "增加设备明细") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwRebackApplyDetailsRequestDTO { | |||
@ApiModelProperty(value = "起始号段", required = true) | |||
@NotBlank(message = "起始号段不能为空") | |||
private Long startId; | |||
@ApiModelProperty(value = "结束号段", required = true) | |||
@NotBlank(message = "结束号段不能为空") | |||
private Long endId; | |||
} |
@@ -0,0 +1,29 @@ | |||
package cn.com.taiji.invw.dto.reback; | |||
import java.time.LocalDateTime; | |||
import cn.com.taiji.core.entity.dict.invw.InvApplyStatus; | |||
import cn.com.taiji.core.entity.dict.invw.InventoryType; | |||
import cn.com.taiji.invw.dto.AbstractBizPageRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
@ApiModel(description = "回收信息分页查询") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwRebackApplyPageRequestDTO extends AbstractBizPageRequestDTO { | |||
@ApiModelProperty(value = "回退仓库") | |||
private String rebackStoreCode; | |||
@ApiModelProperty(value = "接收仓库") | |||
private String receiveStoreCode; | |||
@ApiModelProperty(value = "库存类型") | |||
private InventoryType inventoryType; | |||
@ApiModelProperty(value = "申请状态") | |||
private InvApplyStatus applyStatus; | |||
} |
@@ -0,0 +1,54 @@ | |||
package cn.com.taiji.invw.dto.reback; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
import cn.com.taiji.core.entity.dict.basic.DeviceVersion; | |||
import cn.com.taiji.core.entity.dict.invw.InventoryType; | |||
import cn.com.taiji.core.entity.dict.invw.OwnType; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
import java.util.List; | |||
@ApiModel(description = "回收新增") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwRebackApplyRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "回退仓库(发货仓库)编号", required = true) | |||
@NotBlank(message = "回退仓库编号不能为空") | |||
private String rebackStoreCode; | |||
@ApiModelProperty(value = "接收仓库编号", required = true) | |||
@NotBlank(message = "接收仓库编号不能为空") | |||
private String receiveStoreCode; | |||
@ApiModelProperty(value = "库存类型", required = true) | |||
@NotBlank(message = "库存类型不能为空") | |||
private InventoryType inventoryType; | |||
@ApiModelProperty(value = "品牌,字典新建DEVICE_BRAND", required = true) | |||
@NotBlank(message = "品牌不能为空") | |||
private String brand;//品牌,字典新建DEVICE_BRAND | |||
@ApiModelProperty(value = "设备版本", required = true) | |||
@NotNull(message = "设备版本不能为空") | |||
private DeviceVersion version;//设备版本DeviceVersion | |||
@ApiModelProperty(value = "设备明细", required = true) | |||
@NotBlank(message = "设备明细不能为空") | |||
private List<InvwRebackApplyDetailsRequestDTO> details; | |||
@ApiModelProperty(value = "产权类型") | |||
private OwnType ownType;// 产权类型 | |||
@ApiModelProperty(value = "附件地址") | |||
private String filePath;//附件地址 | |||
} |
@@ -0,0 +1,22 @@ | |||
package cn.com.taiji.invw.dto.reback; | |||
import javax.validation.constraints.NotBlank; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
@ApiModel(description = "回收明细") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwRebackApplyViewRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "id", required = true) | |||
@NotBlank(message = "id不能为空") | |||
private String id; | |||
} |
@@ -0,0 +1,16 @@ | |||
package cn.com.taiji.invw.dto.reback; | |||
import java.util.List; | |||
import cn.com.taiji.core.entity.invw.InvwRebackApply; | |||
import cn.com.taiji.core.entity.invw.InvwRebackApplyDetails; | |||
import cn.com.taiji.invw.dto.warehouse.InvwWarehouseIdNameModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
@Data | |||
public class InvwRebackApplyViewResponseDTO { | |||
private InvwRebackApply rebackApply; | |||
private List<InvwRebackApplyDetails> invwRebackApplyDetailsList; | |||
} |
@@ -0,0 +1,58 @@ | |||
package cn.com.taiji.invw.dto.reback; | |||
import java.util.List; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
import cn.com.taiji.core.entity.dict.basic.DeviceVersion; | |||
import cn.com.taiji.core.entity.dict.invw.InventoryType; | |||
import cn.com.taiji.core.entity.dict.invw.OwnType; | |||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
@ApiModel(description = "回收更改") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwRebackModifyRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "id", required = true) | |||
@NotBlank(message = "id不能为空") | |||
private String id; | |||
@ApiModelProperty(value = "回退仓库(发货仓库)编号", required = true) | |||
@NotBlank(message = "回退仓库编号不能为空") | |||
private String rebackStoreCode; | |||
@ApiModelProperty(value = "接收仓库编号", required = true) | |||
@NotBlank(message = "接收仓库编号不能为空") | |||
private String receiveStoreCode; | |||
@ApiModelProperty(value = "库存类型", required = true) | |||
@NotBlank(message = "库存类型不能为空") | |||
private InventoryType inventoryType; | |||
@ApiModelProperty(value = "品牌,字典新建DEVICE_BRAND", required = true) | |||
@NotBlank(message = "品牌不能为空") | |||
private String brand;//品牌,字典新建DEVICE_BRAND | |||
@ApiModelProperty(value = "设备版本", required = true) | |||
@NotNull(message = "设备版本不能为空") | |||
private DeviceVersion version;//设备版本DeviceVersion | |||
@ApiModelProperty(value = "设备明细", required = true) | |||
@NotBlank(message = "设备明细不能为空") | |||
private List<InvwRebackApplyDetailsRequestDTO> details; | |||
@ApiModelProperty(value = "产权类型") | |||
private OwnType ownType;// 产权类型 | |||
@ApiModelProperty(value = "附件地址") | |||
private String filePath;//附件地址 | |||
} |
@@ -0,0 +1,20 @@ | |||
package cn.com.taiji.invw.manager.reback; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.invw.dto.reback.*; | |||
import cn.com.taiji.invw.dto.warehouse.*; | |||
public interface InvwRebackManager { | |||
Pagination page(InvwRebackApplyPageRequestDTO request); | |||
void add(InvwRebackApplyRequestDTO req) throws ManagerException; | |||
void modify(InvwRebackModifyRequestDTO req) throws ManagerException; | |||
InvwRebackApplyViewResponseDTO view(InvwRebackApplyViewRequestDTO req) throws ManagerException; | |||
void cancel(InvwRebackApplyCancelRequestDTO req) throws ManagerException; | |||
void confirm(InvwRebackApplyConfirmReceiptRequestDTO req) throws ManagerException; | |||
} |
@@ -0,0 +1,183 @@ | |||
package cn.com.taiji.invw.manager.reback; | |||
import java.time.LocalDate; | |||
import java.time.LocalDateTime; | |||
import java.time.format.DateTimeFormatter; | |||
import java.util.List; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.core.entity.dict.invw.InvApplyStatus; | |||
import cn.com.taiji.core.entity.invw.InvwRebackApply; | |||
import cn.com.taiji.core.entity.invw.InvwRebackApplyDetails; | |||
import cn.com.taiji.core.entity.invw.InvwWarehouse; | |||
import cn.com.taiji.core.repo.jpa.invw.InvwRebackApplyDetailsRepo; | |||
import cn.com.taiji.core.repo.jpa.invw.InvwRebackApplyRepo; | |||
import cn.com.taiji.core.repo.jpa.invw.InvwWarehouseRepo; | |||
import cn.com.taiji.core.repo.request.invw.InvwRebackApplyPageRequest; | |||
import cn.com.taiji.invw.dto.reback.*; | |||
import cn.com.taiji.invw.manager.AbstractCommManager; | |||
@Service | |||
public class InvwRebackManagerImpl extends AbstractCommManager implements InvwRebackManager { | |||
@Autowired | |||
private InvwRebackApplyRepo rebackApplyRepo; | |||
@Autowired | |||
private InvwWarehouseRepo warehouseRepo; | |||
@Autowired | |||
private InvwRebackApplyDetailsRepo applyDetailsRepo; | |||
@Override | |||
public Pagination page(InvwRebackApplyPageRequestDTO request) { | |||
InvwRebackApplyPageRequest req = new InvwRebackApplyPageRequest(); | |||
BeanUtils.copyProperties(request, req); | |||
return rebackApplyRepo.page(req); | |||
} | |||
@Override | |||
public void add(InvwRebackApplyRequestDTO req) throws ManagerException { | |||
// 校验仓库信息 | |||
InvwWarehouse rebackStore = warehouseRepo.findById(req.getRebackStoreCode()).orElse(null); | |||
if (rebackStore == null) { | |||
throw new ManagerException("退回仓库不存在"); | |||
} | |||
// 校验上级仓库信息 | |||
InvwWarehouse receiveStore = warehouseRepo.findById(req.getReceiveStoreCode()).orElse(null); | |||
if (!rebackStore.equals(req.getReceiveStoreCode())){ | |||
throw new ManagerException("上级仓库填写不正确"); | |||
} | |||
// 封装 | |||
InvwRebackApply apply = new InvwRebackApply(); | |||
String applyNo = queryMaxId(1); | |||
BeanUtils.copyProperties(req, apply); | |||
apply.setApplyNo(applyNo); | |||
apply.setInsertTime(LocalDateTime.now()); | |||
apply.setApplyStatus(InvApplyStatus.NEW); | |||
apply.setRebackAgencyId(rebackStore.getAgencyId()); | |||
apply.setReceiveAgencyId(receiveStore.getAgencyId()); | |||
apply.setInsertTime(LocalDateTime.now()); | |||
// 计算数量 | |||
int i = 0; | |||
// 循环存明细 | |||
if (!req.getDetails().isEmpty()){ | |||
for (InvwRebackApplyDetailsRequestDTO detail : req.getDetails()){ | |||
InvwRebackApplyDetails applyDetails = new InvwRebackApplyDetails(); | |||
applyDetails.setApplyNo(applyNo); | |||
applyDetails.setStartId(String.valueOf(detail.getStartId())); | |||
applyDetails.setEndId(String.valueOf(detail.getEndId())); | |||
applyDetails.setInsertTime(LocalDateTime.now()); | |||
int a = (int) (detail.getEndId() - detail.getStartId()); | |||
i += a; | |||
applyDetailsRepo.persist(applyDetails); | |||
} | |||
} | |||
apply.setRebackCount(i); | |||
rebackApplyRepo.persist(apply); | |||
} | |||
@Override | |||
public void modify(InvwRebackModifyRequestDTO req) throws ManagerException { | |||
// 查询申请 | |||
InvwRebackApply apply = rebackApplyRepo.findById(req.getId()).orElse(null); | |||
if (apply == null){ | |||
throw new ManagerException("未找到申请"); | |||
} | |||
// 校验仓库信息 | |||
InvwWarehouse rebackStore = warehouseRepo.findById(req.getRebackStoreCode()).orElse(null); | |||
if (rebackStore == null) { | |||
throw new ManagerException("退回仓库不存在"); | |||
} | |||
// 校验上级仓库信息 | |||
InvwWarehouse receiveStore = warehouseRepo.findById(req.getReceiveStoreCode()).orElse(null); | |||
if (!rebackStore.equals(req.getReceiveStoreCode())){ | |||
throw new ManagerException("上级仓库填写不正确"); | |||
} | |||
BeanUtils.copyProperties(req, apply); | |||
apply.setInsertTime(LocalDateTime.now()); | |||
apply.setApplyStatus(InvApplyStatus.NEW); | |||
apply.setRebackAgencyId(rebackStore.getAgencyId()); | |||
apply.setReceiveAgencyId(receiveStore.getAgencyId()); | |||
apply.setInsertTime(LocalDateTime.now()); | |||
// 删除原来的明细单 | |||
List<InvwRebackApplyDetails> list = applyDetailsRepo.listByApplyNo(apply.getApplyNo()); | |||
applyDetailsRepo.deleteAll(list); | |||
// 计算数量 | |||
int i = 0; | |||
// 循环存明细 | |||
if (!req.getDetails().isEmpty()){ | |||
for (InvwRebackApplyDetailsRequestDTO detail : req.getDetails()){ | |||
InvwRebackApplyDetails applyDetails = new InvwRebackApplyDetails(); | |||
applyDetails.setApplyNo(apply.getApplyNo()); | |||
applyDetails.setStartId(String.valueOf(detail.getStartId())); | |||
applyDetails.setEndId(String.valueOf(detail.getEndId())); | |||
applyDetails.setInsertTime(LocalDateTime.now()); | |||
int a = (int) (detail.getEndId() - detail.getStartId()); | |||
i += a; | |||
applyDetailsRepo.persist(applyDetails); | |||
} | |||
} | |||
apply.setRebackCount(i); | |||
rebackApplyRepo.merge(apply); | |||
} | |||
@Override | |||
public InvwRebackApplyViewResponseDTO view(InvwRebackApplyViewRequestDTO req) throws ManagerException { | |||
// 查询申请 | |||
InvwRebackApply apply = rebackApplyRepo.findById(req.getId()).orElse(null); | |||
if (apply == null){ | |||
throw new ManagerException("未找到申请"); | |||
} | |||
// 查询明细单 | |||
List<InvwRebackApplyDetails> list = applyDetailsRepo.listByApplyNo(apply.getApplyNo()); | |||
InvwRebackApplyViewResponseDTO dto = new InvwRebackApplyViewResponseDTO(); | |||
dto.setRebackApply(apply); | |||
dto.setInvwRebackApplyDetailsList(list); | |||
return dto; | |||
} | |||
@Override | |||
public void cancel(InvwRebackApplyCancelRequestDTO req) throws ManagerException { | |||
// 查询申请 | |||
InvwRebackApply apply = rebackApplyRepo.findById(req.getId()).orElse(null); | |||
if (apply == null){ | |||
throw new ManagerException("未找到申请"); | |||
} | |||
apply.setApplyStatus(InvApplyStatus.REJECT); | |||
rebackApplyRepo.merge(apply); | |||
} | |||
@Override | |||
public void confirm(InvwRebackApplyConfirmReceiptRequestDTO req) throws ManagerException { | |||
InvwRebackApply apply = rebackApplyRepo.findById(req.getId()).orElse(null); | |||
if (apply == null){ | |||
throw new ManagerException("未找到申请"); | |||
} | |||
apply.setApplyStatus(InvApplyStatus.COMFIRE); | |||
apply.setReceiveTime(LocalDateTime.now()); | |||
apply.setReceiverId(req.getOpenId()); | |||
} | |||
private String queryMaxId(int num) { | |||
// 获取当天时间 | |||
LocalDate nowDate = LocalDate.now(); | |||
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd"); | |||
String time = dateFormatter.format(nowDate); | |||
// 计算最大id值 | |||
InvwRebackApply maxOrder = rebackApplyRepo.getMaxId(); | |||
if (maxOrder != null && maxOrder.getId().startsWith(time + "")) | |||
{ | |||
String maxId = maxOrder.getId(); | |||
num = Integer.parseInt(maxId.replace(time, "")) + 1; | |||
String.format("%05d",num); | |||
} | |||
return time + String.format("%05d",num); | |||
} | |||
} |
@@ -12,37 +12,37 @@ import cn.com.taiji.invw.repo.jpa.request.SamplePageRequest2; | |||
@SpringBootTest | |||
public class TestSampleRepo extends AbstractManager { | |||
@Autowired | |||
private SampleRepo repo; | |||
@org.junit.jupiter.api.Test | |||
public void testRepo() { | |||
Sample sample = new Sample(); | |||
sample.setName("张三"); | |||
sample.setIdNum("123456789"); | |||
sample.setIntValue(1); | |||
sample.setAddress("贵州"); | |||
System.out.println("*****************-2" + sample); | |||
repo.persist(sample); | |||
System.out.println("*****************-1" + sample); | |||
System.out.println("******************0" + repo.findById(sample.getId()).orElse(null)); | |||
System.out.println("******************0" + sample); | |||
System.out.println("******************1" + repo.listByName("张三"));// 正确 | |||
System.out.println("******************2" + repo.listByNameSql("张三"));// 使用原生sql(nativeQuery)查不出来 | |||
System.out.println("******************3" + repo.listByName("张三-encrypt"));// 查不出来 | |||
System.out.println("******************4" + repo.listByNameSql("张三-encrypt"));// 能查出来,不建议用,结果明文 | |||
System.out.println("******************5" + repo.listPropertyByName("张三"));// 正确 | |||
System.out.println("******************6" + repo.page(new SamplePageRequest1("张三")).getResult()); | |||
System.out.println( | |||
"******************6" + repo.page(new SamplePageRequest2("张三")).getResult(Object[].class).get(0)[0]); | |||
repo.updateName("张三2", "张三"); | |||
System.out.println("*****************11" + sample); | |||
Sample newSample = repo.findById(sample.getId()).orElse(null); | |||
System.out.println("*****************12" + newSample); | |||
newSample.setName("张三3"); | |||
repo.merge(newSample); | |||
System.out.println("*****************13" + repo.findById(sample.getId()).orElse(null)); | |||
} | |||
// @Autowired | |||
// private SampleRepo repo; | |||
// | |||
// @org.junit.jupiter.api.Test | |||
// public void testRepo() { | |||
// Sample sample = new Sample(); | |||
// sample.setName("张三"); | |||
// sample.setIdNum("123456789"); | |||
// sample.setIntValue(1); | |||
// sample.setAddress("贵州"); | |||
// System.out.println("*****************-2" + sample); | |||
// repo.persist(sample); | |||
// System.out.println("*****************-1" + sample); | |||
// System.out.println("******************0" + repo.findById(sample.getId()).orElse(null)); | |||
// System.out.println("******************0" + sample); | |||
// System.out.println("******************1" + repo.listByName("张三"));// 正确 | |||
// System.out.println("******************2" + repo.listByNameSql("张三"));// 使用原生sql(nativeQuery)查不出来 | |||
// System.out.println("******************3" + repo.listByName("张三-encrypt"));// 查不出来 | |||
// System.out.println("******************4" + repo.listByNameSql("张三-encrypt"));// 能查出来,不建议用,结果明文 | |||
// System.out.println("******************5" + repo.listPropertyByName("张三"));// 正确 | |||
// System.out.println("******************6" + repo.page(new SamplePageRequest1("张三")).getResult()); | |||
// System.out.println( | |||
// "******************6" + repo.page(new SamplePageRequest2("张三")).getResult(Object[].class).get(0)[0]); | |||
// repo.updateName("张三2", "张三"); | |||
// System.out.println("*****************11" + sample); | |||
// Sample newSample = repo.findById(sample.getId()).orElse(null); | |||
// System.out.println("*****************12" + newSample); | |||
// newSample.setName("张三3"); | |||
// repo.merge(newSample); | |||
// System.out.println("*****************13" + repo.findById(sample.getId()).orElse(null)); | |||
// | |||
// } | |||
} |