Selaa lähdekoodia

调拨调整

master
yangpeilai 2 viikkoa sitten
vanhempi
commit
5ec20de670

+ 0
- 1
gly-base-core/src/main/java/cn/com/taiji/core/repo/jpa/invw/InvwCardDetailsRepo.java Näytä tiedosto

//根据设备编号范围查询库存 //根据设备编号范围查询库存
@Query(value = "select count(id) from InvwCardDetails where storeCode = ?1 and status = ?2 and cardId >= ?3 and cardId <= ?4 ") @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, InvDeviceStatus status, String cardIdStart, String cardIdEnd);
// long findCountByStoreCodeStatusCardId(String storeCode, Integer status, String cardIdStart, String cardIdEnd);


//修改卡的所属仓库 //修改卡的所属仓库
@Modifying @Modifying

+ 9
- 14
gly-base-core/src/main/java/cn/com/taiji/core/repo/request/invw/InvwTransferApplyPageRequest.java Näytä tiedosto

public class InvwTransferApplyPageRequest extends JpaDateTimePageableDataRequest<InvwTransferApply>{ public class InvwTransferApplyPageRequest extends JpaDateTimePageableDataRequest<InvwTransferApply>{


private String brand;//品牌厂商 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 applyTimeStart;//申请开始时间
private LocalDateTime applyTimeEnd;//申请结束时间 private LocalDateTime applyTimeEnd;//申请结束时间


HqlBuilder hql = new HqlBuilder("from InvwTransferApply where 1=1 "); HqlBuilder hql = new HqlBuilder("from InvwTransferApply where 1=1 ");
if(StringTools.hasText(brand)) if(StringTools.hasText(brand))
hql.append(" and brand =:brand ", 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 >=:applyTimeStart ", applyTimeStart);
hql.append(" and applyTime <=:applyTimeEnd ", applyTimeEnd); hql.append(" and applyTime <=:applyTimeEnd ", applyTimeEnd);
return hql; return hql;
} }





} }

+ 1
- 1
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/api/transfer/InvwTransferApplyController.java Näytä tiedosto



@ApiOperation(value = "04-调拨详情") @ApiOperation(value = "04-调拨详情")
@PostMapping("/detail") @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)); return ApiResponse.of(manager.detail(req));
} }



+ 6
- 0
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/api/warehouse/InvwWarehouseController.java Näytä tiedosto

public ApiResponse<InvwWarehouseIdNameResponseDTO> getWarehouseIdNames(@Valid @RequestBody InvwWarehouseIdNameRequestDTO req) { public ApiResponse<InvwWarehouseIdNameResponseDTO> getWarehouseIdNames(@Valid @RequestBody InvwWarehouseIdNameRequestDTO req) {
return ApiResponse.of(manager.getWarehouseIdNames(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));
}
} }

+ 2
- 0
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/dto/transfer/InvwTransferApplyCancelInRequestDTO.java Näytä tiedosto

@Setter @Setter
@Accessors(chain = true) @Accessors(chain = true)
public class InvwTransferApplyCancelInRequestDTO extends AbstractBizRequestDTO { public class InvwTransferApplyCancelInRequestDTO extends AbstractBizRequestDTO {

@ApiModelProperty(value = "调拨id") @ApiModelProperty(value = "调拨id")
@NotBlank(message = "调拨id不能为空") @NotBlank(message = "调拨id不能为空")
private String id; private String id;

@ApiModelProperty(value = "取消原因") @ApiModelProperty(value = "取消原因")
@NotBlank(message = "取消原因不能为空") @NotBlank(message = "取消原因不能为空")
private String reason; private String reason;

+ 3
- 0
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/dto/transfer/InvwTransferApplyCheckRequestDTO.java Näytä tiedosto

@Setter @Setter
@Accessors(chain = true) @Accessors(chain = true)
public class InvwTransferApplyCheckRequestDTO extends AbstractBizRequestDTO { public class InvwTransferApplyCheckRequestDTO extends AbstractBizRequestDTO {

@ApiModelProperty(value = "发货仓库") @ApiModelProperty(value = "发货仓库")
@NotBlank(message = "发货仓库不能为空") @NotBlank(message = "发货仓库不能为空")
private String sendStoreCode; private String sendStoreCode;

@ApiModelProperty(value = "设备类型") @ApiModelProperty(value = "设备类型")
@NotNull(message = "设备类型不能为空") @NotNull(message = "设备类型不能为空")
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private InventoryType inventoryType;//设备类型 private InventoryType inventoryType;//设备类型

@ApiModelProperty(value = "调拨明细") @ApiModelProperty(value = "调拨明细")
@NotNull(message = "调拨明细不能为空") @NotNull(message = "调拨明细不能为空")
@Valid @Valid

+ 16
- 3
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/dto/transfer/InvwTransferApplyPageRequestDTO.java Näytä tiedosto

package cn.com.taiji.invw.dto.transfer; 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 cn.com.taiji.invw.dto.AbstractBizPageRequestDTO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;


import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import java.time.LocalDateTime; import java.time.LocalDateTime;


@ApiModel(description = "调拨申请分页") @ApiModel(description = "调拨申请分页")
public class InvwTransferApplyPageRequestDTO extends AbstractBizPageRequestDTO { public class InvwTransferApplyPageRequestDTO extends AbstractBizPageRequestDTO {
@ApiModelProperty(value = "品牌厂商") @ApiModelProperty(value = "品牌厂商")
private String brand;//品牌厂商 private String brand;//品牌厂商

@ApiModelProperty(value = "设备类型") @ApiModelProperty(value = "设备类型")
private String inventoryType;//设备类型
@Enumerated(EnumType.STRING)
private InventoryType inventoryType;//设备类型

@ApiModelProperty(value = "设备版本") @ApiModelProperty(value = "设备版本")
private String version;//设备版本
@Enumerated(EnumType.STRING)
private DeviceVersion version;//设备版本

@ApiModelProperty(value = "申请状态") @ApiModelProperty(value = "申请状态")
private String applyStatus;//申请状态
@Enumerated(EnumType.STRING)
private InvApplyStatus applyStatus;//申请状态

@ApiModelProperty(value = "申请开始时间") @ApiModelProperty(value = "申请开始时间")
private LocalDateTime applyTimeStart;//申请开始时间 private LocalDateTime applyTimeStart;//申请开始时间

@ApiModelProperty(value = "申请结束时间") @ApiModelProperty(value = "申请结束时间")
private LocalDateTime applyTimeEnd;//申请结束时间 private LocalDateTime applyTimeEnd;//申请结束时间
} }

+ 1
- 1
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/manager/transfer/InvwTransferApplyManager.java Näytä tiedosto



void edit(InvwTransferApplyEditRequestDTO req) throws ManagerException; void edit(InvwTransferApplyEditRequestDTO req) throws ManagerException;


InvwTransferApplyDetailResponseDTO detail(InvwTransferApplyDetailRequestDTO req) ;
InvwTransferApplyDetailResponseDTO detail(InvwTransferApplyDetailRequestDTO req) throws ManagerException;


void cancelIn(InvwTransferApplyCancelInRequestDTO req) throws ManagerException; void cancelIn(InvwTransferApplyCancelInRequestDTO req) throws ManagerException;



+ 18
- 15
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/manager/transfer/InvwTransferApplyManagerImpl.java Näytä tiedosto

} }


// 调拨申请 // 调拨申请
@Transactional
@Transactional(rollbackFor = Exception.class)
@Override @Override
public void add(InvwTransferApplyAddRequestDTO req) throws ManagerException { public void add(InvwTransferApplyAddRequestDTO req) throws ManagerException {
InvwTransferApply transferApply = new InvwTransferApply(); InvwTransferApply transferApply = new InvwTransferApply();
} }


//修改 //修改
@Transactional
@Transactional(rollbackFor = Exception.class)
@Override @Override
public void edit(InvwTransferApplyEditRequestDTO req) throws ManagerException { public void edit(InvwTransferApplyEditRequestDTO req) throws ManagerException {
InvwTransferApplyCommModel transferApplyModel = req.getTransferApply(); InvwTransferApplyCommModel transferApplyModel = req.getTransferApply();


//详情 //详情
@Override @Override
public InvwTransferApplyDetailResponseDTO detail(InvwTransferApplyDetailRequestDTO req) {
public InvwTransferApplyDetailResponseDTO detail(InvwTransferApplyDetailRequestDTO req) throws ManagerException {
InvwTransferApplyDetailResponseDTO response = new InvwTransferApplyDetailResponseDTO(); InvwTransferApplyDetailResponseDTO response = new InvwTransferApplyDetailResponseDTO();
InvwTransferApply transferApply = transferApplyRepo.findById(req.getId()).orElse(null); InvwTransferApply transferApply = transferApplyRepo.findById(req.getId()).orElse(null);
if (transferApply == null) {
throw new ManagerException("调拨申请不存在");
}
List<InvwTransferApplyDetails> details = transferDetailsRepo.findByApplyNo(transferApply.getApplyNo()); List<InvwTransferApplyDetails> details = transferDetailsRepo.findByApplyNo(transferApply.getApplyNo());
response.setTransferDetails(details); response.setTransferDetails(details);
response.setTransferApply(transferApply); response.setTransferApply(transferApply);
} }


// 确认入库 // 确认入库
@Transactional
@Transactional(rollbackFor = Exception.class)
@Override @Override
public void confirmIn(InvwTransferApplyConfirmInRequestDTO req) throws ManagerException { public void confirmIn(InvwTransferApplyConfirmInRequestDTO req) throws ManagerException {
InvwTransferApply transferApply = transferApplyRepo.findById(req.getId()).orElse(null); InvwTransferApply transferApply = transferApplyRepo.findById(req.getId()).orElse(null);
InvwTransferApplyCommModel transferApplyModel = addReq.getTransferApply(); InvwTransferApplyCommModel transferApplyModel = addReq.getTransferApply();
InvwTransferApplyDetailsModel[] detailsModels = addReq.getTransferDetails(); InvwTransferApplyDetailsModel[] detailsModels = addReq.getTransferDetails();


transferApplyModel.valid("add");

LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
//生成申请单号 //生成申请单号
String applyNo = GenerateNoUtil.generateApplyNo(); String applyNo = GenerateNoUtil.generateApplyNo();
private void handleEditRequest(InvwTransferApplyEditRequestDTO editReq, InvwTransferApply transferApply, List<InvwTransferApplyDetails> transferApplyDetails) throws ManagerException { private void handleEditRequest(InvwTransferApplyEditRequestDTO editReq, InvwTransferApply transferApply, List<InvwTransferApplyDetails> transferApplyDetails) throws ManagerException {
InvwTransferApplyCommModel transferApplyModel = editReq.getTransferApply(); InvwTransferApplyCommModel transferApplyModel = editReq.getTransferApply();
InvwTransferApplyDetailsModel[] transferModelDetails = editReq.getTransferDetails(); InvwTransferApplyDetailsModel[] transferModelDetails = editReq.getTransferDetails();
transferApplyModel.valid("edit");
if(!StringTools.hasText(transferApplyModel.getId())){
throw new ManagerException("调拨id不能为空");
}


transferApply.setOpenId(editReq.getOpenId()); transferApply.setOpenId(editReq.getOpenId());
//设置申请单信息 //设置申请单信息
if (details == null) { if (details == null) {
throw new ManagerException("调拨申请失败,请检查调拨明细是否正确"); throw new ManagerException("调拨申请失败,请检查调拨明细是否正确");
} }
details.valid();
String startId = details.getStartId(); String startId = details.getStartId();
String endId = details.getEndId(); 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("调拨申请失败,结束编号不能小于起始编号"); throw new ManagerException("调拨申请失败,结束编号不能小于起始编号");
} }
long total = bLong - aLong + 1;
long total = end - start + 1;
long count = 0; 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, InvDeviceStatus.NEW, details.getStartId(), details.getEndId());
// count = cardDetailsRepo.findCountByStoreCodeStatusCardId(sendStoreCode, 1, 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()); count = obuDetailsRepo.findCountByStoreCodeStatusObuId(sendStoreCode, InvDeviceStatus.NEW, details.getStartId(), details.getEndId());
} else { } else {
throw new ManagerException("调拨申请失败,请检查设备类型是否正确"); throw new ManagerException("调拨申请失败,请检查设备类型是否正确");
} }
if (count != total) { if (count != total) {
throw new ManagerException("库存校验失败");
throw new ManagerException("库存校验失败,该仓库["+start+"-"+end+"]号段在库设备量为:"+count);
} }
return total; return total;
} }

+ 0
- 15
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/model/transfer/InvwTransferApplyCommModel.java Näytä tiedosto

package cn.com.taiji.invw.model.transfer; 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.CardType;
import cn.com.taiji.core.entity.dict.basic.DeviceVersion; 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.basic.ObuType;
import cn.com.taiji.core.entity.dict.invw.InvApplyStatus; 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.InventoryType;
import cn.com.taiji.core.entity.dict.invw.OwnType; 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.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
@ApiModelProperty(value = "附件地址") @ApiModelProperty(value = "附件地址")
private String filePath;//附件地址 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
- 16
zhywpt-app-invw/src/main/java/cn/com/taiji/invw/model/transfer/InvwTransferApplyDetailsModel.java Näytä tiedosto

package cn.com.taiji.invw.model.transfer; 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.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
@NotBlank(message = "开始编号不能为空") @NotBlank(message = "开始编号不能为空")
@Pattern(regexp = "^[0-9]*$", message = "编号只能由0-9组成") @Pattern(regexp = "^[0-9]*$", message = "编号只能由0-9组成")
private String startId;//开始编号 private String startId;//开始编号

@ApiModelProperty(value = "结束编号") @ApiModelProperty(value = "结束编号")
@NotBlank(message = "结束编号不能为空") @NotBlank(message = "结束编号不能为空")
@Pattern(regexp = "^[0-9]*$", message = "编号只能由0-9组成") @Pattern(regexp = "^[0-9]*$", message = "编号只能由0-9组成")
private String endId;//结束编号 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());
}
} }

Loading…
Peruuta
Tallenna