@@ -21,7 +21,6 @@ public interface InvwCardDetailsRepo extends AbstractJpaRepo<InvwCardDetails, St | |||
//根据设备编号范围查询库存 | |||
@Query(value = "select count(id) from InvwCardDetails where storeCode = ?1 and status = ?2 and cardId >= ?3 and cardId <= ?4 ") | |||
long findCountByStoreCodeStatusCardId(String storeCode, InvDeviceStatus status, String cardIdStart, String cardIdEnd); | |||
// long findCountByStoreCodeStatusCardId(String storeCode, Integer status, String cardIdStart, String cardIdEnd); | |||
//修改卡的所属仓库 | |||
@Modifying |
@@ -17,9 +17,9 @@ import java.time.LocalDateTime; | |||
public class InvwTransferApplyPageRequest extends JpaDateTimePageableDataRequest<InvwTransferApply>{ | |||
private String brand;//品牌厂商 | |||
private String inventoryType;//设备类型 | |||
private String version;//设备版本 | |||
private String applyStatus;//申请状态 | |||
private InventoryType inventoryType;//设备类型 | |||
private DeviceVersion version;//设备版本 | |||
private InvApplyStatus applyStatus;//申请状态 | |||
private LocalDateTime applyTimeStart;//申请开始时间 | |||
private LocalDateTime applyTimeEnd;//申请结束时间 | |||
@@ -34,19 +34,14 @@ public class InvwTransferApplyPageRequest extends JpaDateTimePageableDataRequest | |||
HqlBuilder hql = new HqlBuilder("from InvwTransferApply where 1=1 "); | |||
if(StringTools.hasText(brand)) | |||
hql.append(" and brand =:brand ", brand); | |||
if(StringTools.hasText(inventoryType)) | |||
hql.append(" and inventoryType =:inventoryType ", InventoryType.valueOf(inventoryType)); | |||
if(StringTools.hasText(version)) | |||
hql.append(" and version =:version ", DeviceVersion.valueOf(version)); | |||
if(StringTools.hasText(applyStatus)) | |||
hql.append(" and applyStatus =:applyStatus ", InvApplyStatus.valueOf(applyStatus)); | |||
if(inventoryType!=null) | |||
hql.append(" and inventoryType =:inventoryType ", inventoryType); | |||
if(version!=null) | |||
hql.append(" and version =:version ", version); | |||
if(applyStatus!=null) | |||
hql.append(" and applyStatus =:applyStatus ", applyStatus); | |||
hql.append(" and applyTime >=:applyTimeStart ", applyTimeStart); | |||
hql.append(" and applyTime <=:applyTimeEnd ", applyTimeEnd); | |||
return hql; | |||
} | |||
} |
@@ -52,7 +52,7 @@ public class InvwTransferApplyController extends MyValidController { | |||
@ApiOperation(value = "04-调拨详情") | |||
@PostMapping("/detail") | |||
public ApiResponse<InvwTransferApplyDetailResponseDTO> detail(@Valid @RequestBody InvwTransferApplyDetailRequestDTO req) { | |||
public ApiResponse<InvwTransferApplyDetailResponseDTO> detail(@Valid @RequestBody InvwTransferApplyDetailRequestDTO req) throws ManagerException { | |||
return ApiResponse.of(manager.detail(req)); | |||
} | |||
@@ -64,4 +64,10 @@ public class InvwWarehouseController extends MyValidController { | |||
public ApiResponse<InvwWarehouseIdNameResponseDTO> getWarehouseIdNames(@Valid @RequestBody InvwWarehouseIdNameRequestDTO req) { | |||
return ApiResponse.of(manager.getWarehouseIdNames(req)); | |||
} | |||
@ApiOperation(value = "07-仓库详情") | |||
@PostMapping("/detail") | |||
public ApiResponse<InvwWarehouseDetailResponseDTO> detail(@Valid @RequestBody InvwWarehouseDetailRequestDTO req) throws ManagerException { | |||
return ApiResponse.of(manager.detail(req)); | |||
} | |||
} |
@@ -14,9 +14,11 @@ import javax.validation.constraints.NotBlank; | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwTransferApplyCancelInRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "调拨id") | |||
@NotBlank(message = "调拨id不能为空") | |||
private String id; | |||
@ApiModelProperty(value = "取消原因") | |||
@NotBlank(message = "取消原因不能为空") | |||
private String reason; |
@@ -21,13 +21,16 @@ import javax.validation.constraints.Null; | |||
@Setter | |||
@Accessors(chain = true) | |||
public class InvwTransferApplyCheckRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "发货仓库") | |||
@NotBlank(message = "发货仓库不能为空") | |||
private String sendStoreCode; | |||
@ApiModelProperty(value = "设备类型") | |||
@NotNull(message = "设备类型不能为空") | |||
@Enumerated(EnumType.STRING) | |||
private InventoryType inventoryType;//设备类型 | |||
@ApiModelProperty(value = "调拨明细") | |||
@NotNull(message = "调拨明细不能为空") | |||
@Valid |
@@ -1,5 +1,8 @@ | |||
package cn.com.taiji.invw.dto.transfer; | |||
import cn.com.taiji.core.entity.dict.basic.DeviceVersion; | |||
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; | |||
@@ -7,6 +10,8 @@ import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
import javax.persistence.EnumType; | |||
import javax.persistence.Enumerated; | |||
import java.time.LocalDateTime; | |||
@ApiModel(description = "调拨申请分页") | |||
@@ -16,14 +21,22 @@ import java.time.LocalDateTime; | |||
public class InvwTransferApplyPageRequestDTO extends AbstractBizPageRequestDTO { | |||
@ApiModelProperty(value = "品牌厂商") | |||
private String brand;//品牌厂商 | |||
@ApiModelProperty(value = "设备类型") | |||
private String inventoryType;//设备类型 | |||
@Enumerated(EnumType.STRING) | |||
private InventoryType inventoryType;//设备类型 | |||
@ApiModelProperty(value = "设备版本") | |||
private String version;//设备版本 | |||
@Enumerated(EnumType.STRING) | |||
private DeviceVersion version;//设备版本 | |||
@ApiModelProperty(value = "申请状态") | |||
private String applyStatus;//申请状态 | |||
@Enumerated(EnumType.STRING) | |||
private InvApplyStatus applyStatus;//申请状态 | |||
@ApiModelProperty(value = "申请开始时间") | |||
private LocalDateTime applyTimeStart;//申请开始时间 | |||
@ApiModelProperty(value = "申请结束时间") | |||
private LocalDateTime applyTimeEnd;//申请结束时间 | |||
} |
@@ -11,7 +11,7 @@ public interface InvwTransferApplyManager { | |||
void edit(InvwTransferApplyEditRequestDTO req) throws ManagerException; | |||
InvwTransferApplyDetailResponseDTO detail(InvwTransferApplyDetailRequestDTO req) ; | |||
InvwTransferApplyDetailResponseDTO detail(InvwTransferApplyDetailRequestDTO req) throws ManagerException; | |||
void cancelIn(InvwTransferApplyCancelInRequestDTO req) throws ManagerException; | |||
@@ -51,7 +51,7 @@ public class InvwTransferApplyManagerImpl extends AbstractCommManager implements | |||
} | |||
// 调拨申请 | |||
@Transactional | |||
@Transactional(rollbackFor = Exception.class) | |||
@Override | |||
public void add(InvwTransferApplyAddRequestDTO req) throws ManagerException { | |||
InvwTransferApply transferApply = new InvwTransferApply(); | |||
@@ -63,7 +63,7 @@ public class InvwTransferApplyManagerImpl extends AbstractCommManager implements | |||
} | |||
//修改 | |||
@Transactional | |||
@Transactional(rollbackFor = Exception.class) | |||
@Override | |||
public void edit(InvwTransferApplyEditRequestDTO req) throws ManagerException { | |||
InvwTransferApplyCommModel transferApplyModel = req.getTransferApply(); | |||
@@ -89,9 +89,12 @@ public class InvwTransferApplyManagerImpl extends AbstractCommManager implements | |||
//详情 | |||
@Override | |||
public InvwTransferApplyDetailResponseDTO detail(InvwTransferApplyDetailRequestDTO req) { | |||
public InvwTransferApplyDetailResponseDTO detail(InvwTransferApplyDetailRequestDTO req) throws ManagerException { | |||
InvwTransferApplyDetailResponseDTO response = new InvwTransferApplyDetailResponseDTO(); | |||
InvwTransferApply transferApply = transferApplyRepo.findById(req.getId()).orElse(null); | |||
if (transferApply == null) { | |||
throw new ManagerException("调拨申请不存在"); | |||
} | |||
List<InvwTransferApplyDetails> details = transferDetailsRepo.findByApplyNo(transferApply.getApplyNo()); | |||
response.setTransferDetails(details); | |||
response.setTransferApply(transferApply); | |||
@@ -114,7 +117,7 @@ public class InvwTransferApplyManagerImpl extends AbstractCommManager implements | |||
} | |||
// 确认入库 | |||
@Transactional | |||
@Transactional(rollbackFor = Exception.class) | |||
@Override | |||
public void confirmIn(InvwTransferApplyConfirmInRequestDTO req) throws ManagerException { | |||
InvwTransferApply transferApply = transferApplyRepo.findById(req.getId()).orElse(null); | |||
@@ -184,8 +187,6 @@ public class InvwTransferApplyManagerImpl extends AbstractCommManager implements | |||
InvwTransferApplyCommModel transferApplyModel = addReq.getTransferApply(); | |||
InvwTransferApplyDetailsModel[] detailsModels = addReq.getTransferDetails(); | |||
transferApplyModel.valid("add"); | |||
LocalDateTime now = LocalDateTime.now(); | |||
//生成申请单号 | |||
String applyNo = GenerateNoUtil.generateApplyNo(); | |||
@@ -225,7 +226,9 @@ public class InvwTransferApplyManagerImpl extends AbstractCommManager implements | |||
private void handleEditRequest(InvwTransferApplyEditRequestDTO editReq, InvwTransferApply transferApply, List<InvwTransferApplyDetails> transferApplyDetails) throws ManagerException { | |||
InvwTransferApplyCommModel transferApplyModel = editReq.getTransferApply(); | |||
InvwTransferApplyDetailsModel[] transferModelDetails = editReq.getTransferDetails(); | |||
transferApplyModel.valid("edit"); | |||
if(!StringTools.hasText(transferApplyModel.getId())){ | |||
throw new ManagerException("调拨id不能为空"); | |||
} | |||
transferApply.setOpenId(editReq.getOpenId()); | |||
//设置申请单信息 | |||
@@ -306,26 +309,26 @@ public class InvwTransferApplyManagerImpl extends AbstractCommManager implements | |||
if (details == null) { | |||
throw new ManagerException("调拨申请失败,请检查调拨明细是否正确"); | |||
} | |||
details.valid(); | |||
String startId = details.getStartId(); | |||
String endId = details.getEndId(); | |||
long aLong = Long.parseLong(startId); | |||
long bLong = Long.parseLong(endId); | |||
if (aLong > bLong) { | |||
long start = Long.parseLong(startId); | |||
long end = Long.parseLong(endId); | |||
if (end < start) { | |||
throw new ManagerException("调拨申请失败,结束编号不能小于起始编号"); | |||
} | |||
long total = bLong - aLong + 1; | |||
long total = end - start + 1; | |||
long count = 0; | |||
if (InventoryType.CARD.name().equals(inventoryType)) { | |||
if (InventoryType.CARD == inventoryType) { | |||
count = cardDetailsRepo.findCountByStoreCodeStatusCardId(sendStoreCode, InvDeviceStatus.NEW, details.getStartId(), details.getEndId()); | |||
// count = cardDetailsRepo.findCountByStoreCodeStatusCardId(sendStoreCode, 1, details.getStartId(), details.getEndId()); | |||
} else if (InventoryType.OBU.name().equals(inventoryType)) { | |||
} else if (InventoryType.OBU == inventoryType) { | |||
count = obuDetailsRepo.findCountByStoreCodeStatusObuId(sendStoreCode, InvDeviceStatus.NEW, details.getStartId(), details.getEndId()); | |||
} else { | |||
throw new ManagerException("调拨申请失败,请检查设备类型是否正确"); | |||
} | |||
if (count != total) { | |||
throw new ManagerException("库存校验失败"); | |||
throw new ManagerException("库存校验失败,该仓库["+start+"-"+end+"]号段在库设备量为:"+count); | |||
} | |||
return total; | |||
} |
@@ -1,13 +1,11 @@ | |||
package cn.com.taiji.invw.model.transfer; | |||
import cn.com.taiji.common.pub.StringTools; | |||
import cn.com.taiji.core.entity.dict.basic.CardType; | |||
import cn.com.taiji.core.entity.dict.basic.DeviceVersion; | |||
import cn.com.taiji.core.entity.dict.basic.ObuType; | |||
import cn.com.taiji.core.entity.dict.invw.InvApplyStatus; | |||
import cn.com.taiji.core.entity.dict.invw.InventoryType; | |||
import cn.com.taiji.core.entity.dict.invw.OwnType; | |||
import cn.com.taiji.invw.model.FormatException; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
@@ -74,17 +72,4 @@ public class InvwTransferApplyCommModel { | |||
@ApiModelProperty(value = "附件地址") | |||
private String filePath;//附件地址 | |||
public void valid(String type) throws FormatException { | |||
StringBuffer msg = new StringBuffer(); | |||
if("edit".equals(type)){ | |||
if(!StringTools.hasText(id)) msg.append("调拨id不能为空,"); | |||
} | |||
// if (!StringTools.hasText(inventoryType)) msg.append("设备类型不能为空,"); | |||
// if (!StringTools.hasText(ownType)) msg.append("产权类型不能为空,"); | |||
// if (!StringTools.hasText(brand)) msg.append("品牌厂商不能为空,"); | |||
// if (!StringTools.hasText(version)) msg.append("设备版本不能为空,"); | |||
// if (!StringTools.hasText(applyType)) msg.append("申请类型不能为空,"); | |||
// if (!StringTools.hasText(sendStoreCode)) msg.append("发货仓库不能为空"); | |||
if(StringTools.hasText(msg)) throw new FormatException(msg.toString()); | |||
} | |||
} |
@@ -1,7 +1,5 @@ | |||
package cn.com.taiji.invw.model.transfer; | |||
import cn.com.taiji.common.pub.StringTools; | |||
import cn.com.taiji.invw.model.FormatException; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
@@ -24,23 +22,10 @@ public class InvwTransferApplyDetailsModel { | |||
@NotBlank(message = "开始编号不能为空") | |||
@Pattern(regexp = "^[0-9]*$", message = "编号只能由0-9组成") | |||
private String startId;//开始编号 | |||
@ApiModelProperty(value = "结束编号") | |||
@NotBlank(message = "结束编号不能为空") | |||
@Pattern(regexp = "^[0-9]*$", message = "编号只能由0-9组成") | |||
private String endId;//结束编号 | |||
public void valid() throws FormatException { | |||
StringBuffer msg = new StringBuffer(); | |||
if (!StringTools.hasText(startId)) msg.append("开始编号不能为空,"); | |||
if (!StringTools.hasText(endId)) msg.append("结束编号不能为空,"); | |||
String regex = "^[0-9]*$"; // 仅允许数字 | |||
if (!startId.matches(regex)) { | |||
msg.append("开始编号格式不正确,只能由数字组成,"); | |||
} | |||
if (!endId.matches(regex)) { | |||
msg.append("结束编号格式不正确,只能由数字组成,"); | |||
} | |||
if (StringTools.hasText(msg)) throw new FormatException(msg.toString()); | |||
} | |||
} |