ORDER_ADDRESS("收货地址管理"), | ORDER_ADDRESS("收货地址管理"), | ||||
REFUND_RECEIVE("退费接收信息管理"), | REFUND_RECEIVE("退费接收信息管理"), | ||||
//入库 | |||||
ENTER_APPLY("入库申请"), | |||||
UPDATE_ENTER_APPLY("修改入库申请"), | |||||
CONFIRM_ENTER_APPLY("确认入库"), | |||||
CANCEL_ENTER_APPLY("取消入库"), | |||||
; | ; | ||||
private final String value; | private final String value; | ||||
@Table(name = "INVW_CARD_DETAILS") | @Table(name = "INVW_CARD_DETAILS") | ||||
public class InvwCardDetails extends StringPropertyUUIDEntity { | public class InvwCardDetails extends StringPropertyUUIDEntity { | ||||
@NotBlank | |||||
@Size(max = 32) | @Size(max = 32) | ||||
@Column(name = "BATCH_ID") | @Column(name = "BATCH_ID") | ||||
private String batchId;//入库批次编号 | private String batchId;//入库批次编号 |
@Table(name = "INVW_OBU_DETAILS") | @Table(name = "INVW_OBU_DETAILS") | ||||
public class InvwObuDetails extends StringPropertyUUIDEntity { | public class InvwObuDetails extends StringPropertyUUIDEntity { | ||||
@NotBlank | |||||
@Size(max = 32) | @Size(max = 32) | ||||
@Column(name = "BATCH_ID") | @Column(name = "BATCH_ID") | ||||
private String batchId;//入库批次编号 | private String batchId;//入库批次编号 |
package cn.com.taiji.core.manager.comm; | |||||
import cn.com.taiji.core.entity.dict.basic.SourceType; | |||||
import cn.com.taiji.core.entity.dict.log.OperateType; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 17:57 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
public interface OperateLogManager { | |||||
void persistOperateLog(OperateType operateType, String operatorDataId, SourceType source, | |||||
String openId, String msg, String ip); | |||||
} |
@Query(value = "from InvwCardDetails where storeCode = ?1") | @Query(value = "from InvwCardDetails where storeCode = ?1") | ||||
List<InvwCardDetails> findByStoreCode(String storeCode); | List<InvwCardDetails> findByStoreCode(String storeCode); | ||||
@Query(" from InvwCardDetails where TO_NUMBER(cardId) >= TO_NUMBER(?1) and TO_NUMBER(cardId) <= TO_NUMBER(?2)") | |||||
List<InvwCardDetails> queryByCardIdBetween(String startId, String endId); | |||||
@Query(value = "select count(id) from InvwCardDetails where storeCode = ?1") | @Query(value = "select count(id) from InvwCardDetails where storeCode = ?1") | ||||
long findCountByStoreCode(String storeCode); | long findCountByStoreCode(String storeCode); | ||||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | ||||
import cn.com.taiji.core.entity.invw.InvwEnterApplyDetails; | import cn.com.taiji.core.entity.invw.InvwEnterApplyDetails; | ||||
import org.springframework.data.jpa.repository.Modifying; | |||||
import org.springframework.data.jpa.repository.Query; | |||||
import org.springframework.transaction.annotation.Transactional; | |||||
import java.util.List; | |||||
public interface InvwEnterApplyDetailsRepo extends AbstractJpaRepo<InvwEnterApplyDetails, String>{ | public interface InvwEnterApplyDetailsRepo extends AbstractJpaRepo<InvwEnterApplyDetails, String>{ | ||||
@Transactional | |||||
@Modifying | |||||
@Query("delete from InvwEnterApplyDetails where applyNo = ?1") | |||||
void deleteByApplyNo(String applyNo); | |||||
@Query(" from InvwEnterApplyDetails where applyNo = ?1") | |||||
List<InvwEnterApplyDetails> queryByApplyNo(String applyNo); | |||||
} | } |
package cn.com.taiji.core.repo.jpa.invw; | package cn.com.taiji.core.repo.jpa.invw; | ||||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | ||||
import cn.com.taiji.core.entity.invw.InvwCardDetails; | |||||
import cn.com.taiji.core.entity.dict.invw.InvDeviceStatus; | import cn.com.taiji.core.entity.dict.invw.InvDeviceStatus; | ||||
import cn.com.taiji.core.entity.invw.InvwObuDetails; | import cn.com.taiji.core.entity.invw.InvwObuDetails; | ||||
import org.springframework.data.jpa.repository.Modifying; | import org.springframework.data.jpa.repository.Modifying; | ||||
@Query(value = "update InvwObuDetails set storeCode = ?1,agencyId=?2,channelId=?3 " + | @Query(value = "update InvwObuDetails set storeCode = ?1,agencyId=?2,channelId=?3 " + | ||||
" where storeCode = ?4 and status = ?5 and cardId >= ?6 and cardId <= ?7") | " where storeCode = ?4 and status = ?5 and cardId >= ?6 and cardId <= ?7") | ||||
int updateStoreCodeByStoreCode(String storeCode, String agencyId, String channelId, String oldStoreCode, InvDeviceStatus status, String cardIdStart, String cardIdEnd); | int updateStoreCodeByStoreCode(String storeCode, String agencyId, String channelId, String oldStoreCode, InvDeviceStatus status, String cardIdStart, String cardIdEnd); | ||||
@Query(" from InvwObuDetails where TO_NUMBER(obuId) >= TO_NUMBER(?1) and TO_NUMBER(obuId) <= TO_NUMBER(?2)") | |||||
List<InvwObuDetails> queryByObuIdBetween(String startId, String endId); | |||||
} | } |
runtimeOnly 'com.oracle.database.jdbc:ojdbc8:19.10.0.0' | runtimeOnly 'com.oracle.database.jdbc:ojdbc8:19.10.0.0' | ||||
runtimeOnly 'cn.easyproject:orai18n:12.1.0.2.0' | runtimeOnly 'cn.easyproject:orai18n:12.1.0.2.0' | ||||
// 添加 MapStruct 核心库依赖 | |||||
implementation 'org.mapstruct:mapstruct:1.5.5.Final' | |||||
// 添加 MapStruct 注解处理器依赖 | |||||
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final' | |||||
} | } | ||||
bootJar { | bootJar { |
import cn.com.taiji.common.model.dao.Pagination; | import cn.com.taiji.common.model.dao.Pagination; | ||||
import cn.com.taiji.common.web.ApiResponse; | import cn.com.taiji.common.web.ApiResponse; | ||||
import cn.com.taiji.invw.api.MyValidController; | import cn.com.taiji.invw.api.MyValidController; | ||||
import cn.com.taiji.invw.dto.enter.InvwEnterApplyInfoApplyRequestDTO; | |||||
import cn.com.taiji.invw.dto.enter.InvwEnterApplyInfoApplyResponseDTO; | |||||
import cn.com.taiji.invw.dto.enter.InvwEnterApplyPageRequestDTO; | |||||
import cn.com.taiji.invw.dto.enter.*; | |||||
import cn.com.taiji.invw.manager.enter.InvwEnterApplyManager; | import cn.com.taiji.invw.manager.enter.InvwEnterApplyManager; | ||||
import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
* @email: huminghao@mail.taiji.com.cn | * @email: huminghao@mail.taiji.com.cn | ||||
* @version: 1.0 | * @version: 1.0 | ||||
*/ | */ | ||||
@Api(tags = {"入库申请"}) | |||||
@Api(tags = {"入库管理"}) | |||||
@RestController | @RestController | ||||
@RequestMapping("/api/enterApply") | @RequestMapping("/api/enterApply") | ||||
public class InvwEnterApplyController extends MyValidController { | |||||
class InvwEnterApplyController extends MyValidController { | |||||
@Autowired | @Autowired | ||||
private InvwEnterApplyManager manager; | private InvwEnterApplyManager manager; | ||||
@ApiOperation("入库提交申请") | @ApiOperation("入库提交申请") | ||||
@PostMapping("/apply") | @PostMapping("/apply") | ||||
public ApiResponse<InvwEnterApplyInfoApplyResponseDTO> apply(@Valid @RequestBody InvwEnterApplyInfoApplyRequestDTO dto) throws ManagerException { | |||||
public ApiResponse<InvwEnterApplyAddResponseDTO> apply(@Valid @RequestBody InvwEnterApplyAddRequestDTO dto) throws ManagerException { | |||||
return ApiResponse.of(manager.apply(dto)).setMessage("入库申请提交成功"); | return ApiResponse.of(manager.apply(dto)).setMessage("入库申请提交成功"); | ||||
} | } | ||||
@ApiOperation("入库申请信息详情") | |||||
@PostMapping("/view") | |||||
public ApiResponse<InvwEnterApplyViewResponseDTO> view(@Valid @RequestBody InvwEnterApplyViewRequestDTO dto) throws ManagerException { | |||||
return ApiResponse.of(manager.view(dto)).setMessage("入库申请信息详情查询完成"); | |||||
} | |||||
@ApiOperation("入库申请信息修改提交") | |||||
@PostMapping("/update") | |||||
public ApiResponse<InvwEnterApplyUpdateResponseDTO> update(@Valid @RequestBody InvwEnterApplyUpdateRequestDTO dto) throws ManagerException { | |||||
return ApiResponse.of(manager.update(dto)).setMessage("入库申请信息修改成功"); | |||||
} | |||||
@ApiOperation("确认入库") | |||||
@PostMapping("/confirm") | |||||
public ApiResponse<InvwEnterApplyConfirmResponseDTO> confirm(@Valid @RequestBody InvwEnterApplyConfirmRequestDTO dto) throws ManagerException { | |||||
return ApiResponse.of(manager.confirm(dto)).setMessage("确认入库提交成功"); | |||||
} | |||||
@ApiOperation("取消入库") | |||||
@PostMapping("/cancel") | |||||
public ApiResponse<InvwEnterApplyCancelResponseDTO> cancel(@Valid @RequestBody InvwEnterApplyCancelRequestDTO dto) throws ManagerException { | |||||
return ApiResponse.of(manager.cancel(dto)).setMessage("取消入库提交成功"); | |||||
} | |||||
@ApiOperation("号段校验") | |||||
@PostMapping("/codeValid") | |||||
public ApiResponse<InvwEnterApplyCodeValidResponseDTO> codeValid(@Valid @RequestBody InvwEnterApplyCodeValidRequestDTO dto) throws ManagerException { | |||||
return ApiResponse.of(manager.codeValid(dto)).setMessage("号段校验完成"); | |||||
} | |||||
@ApiOperation("解析excel获取号段") | |||||
@PostMapping("/parseExcel") | |||||
public ApiResponse<InvwEnterApplyParseExcelResponseDTO> parseExcel(@Valid @RequestBody InvwEnterApplyParseExcelRequestDTO dto) throws ManagerException { | |||||
return ApiResponse.of(manager.parseExcel(dto)).setMessage("excel数据输出完成"); | |||||
} | |||||
} | } |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
import cn.com.taiji.common.pub.CollectionTools; | |||||
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.InventoryType; | |||||
import cn.com.taiji.core.entity.dict.invw.OwnType; | |||||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||||
import cn.com.taiji.invw.model.enter.EnterApplyDetailModel; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import javax.persistence.EnumType; | |||||
import javax.persistence.Enumerated; | |||||
import javax.validation.constraints.NotBlank; | |||||
import javax.validation.constraints.NotNull; | |||||
import java.math.BigInteger; | |||||
import java.util.List; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "入库申请请求") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyAddRequestDTO extends AbstractBizRequestDTO { | |||||
@ApiModelProperty(value = "仓库编号") | |||||
@NotBlank | |||||
private String storeCode; | |||||
@ApiModelProperty(value = "仓库渠道编号") | |||||
private String agencyId; | |||||
@ApiModelProperty(value = "库存类型:卡、签") | |||||
@NotNull | |||||
@Enumerated(EnumType.STRING) | |||||
private InventoryType inventoryType; | |||||
@ApiModelProperty(value = "库存型号") | |||||
@NotNull | |||||
@Enumerated(EnumType.STRING) | |||||
private DeviceVersion version; | |||||
@ApiModelProperty(value = "采购厂商") | |||||
@NotBlank | |||||
private String brand; | |||||
@ApiModelProperty(value = "卡类型") | |||||
@Enumerated(EnumType.STRING) | |||||
private CardType cardType; | |||||
@ApiModelProperty(value = "签类型") | |||||
@Enumerated(EnumType.STRING) | |||||
private ObuType obuType; | |||||
@ApiModelProperty(value = "单价") | |||||
private Long unitPrice; | |||||
@ApiModelProperty(value = "产权类型") | |||||
@NotNull | |||||
@Enumerated(EnumType.STRING) | |||||
private OwnType ownType; | |||||
@ApiModelProperty(value = "附件地址") | |||||
private String filePath; | |||||
@ApiModelProperty(value = "起始-结束号段list") | |||||
@NotNull | |||||
private List<EnterApplyDetailModel> enterApplyDetailModels; | |||||
public void valid() throws ManagerException { | |||||
if (InventoryType.CARD.equals(inventoryType)){ | |||||
if (cardType == null){ | |||||
throw new ManagerException("未选择卡类型"); | |||||
} | |||||
for (EnterApplyDetailModel detailModel : enterApplyDetailModels) { | |||||
if (detailModel.getStartId().length() != 20 || detailModel.getEndId().length() != 20){ | |||||
throw new ManagerException("卡号长度必须为20"); | |||||
} | |||||
} | |||||
}else if (InventoryType.OBU.equals(inventoryType)){ | |||||
if (obuType == null){ | |||||
throw new ManagerException("未选择签类型"); | |||||
} | |||||
for (EnterApplyDetailModel detailModel : enterApplyDetailModels) { | |||||
if (StringUtils.isEmpty(detailModel.getStartId()) || StringUtils.isEmpty(detailModel.getEndId())){ | |||||
throw new ManagerException("起始或结束号段未填写完整"); | |||||
} | |||||
if (detailModel.getStartId().length() != 16 || detailModel.getEndId().length() != 16){ | |||||
throw new ManagerException("签号长度必须为16"); | |||||
} | |||||
} | |||||
if (ObuType.SINGLE_CHIP.equals(obuType)){ | |||||
if (cardType == null){ | |||||
throw new ManagerException("单片式OBU时,卡类型必填"); | |||||
} | |||||
for (EnterApplyDetailModel detailModel : enterApplyDetailModels) { | |||||
int obuNUm = new BigInteger(detailModel.getEndId()).subtract(new BigInteger(detailModel.getStartId())).intValueExact()+1; | |||||
int cardNUm = new BigInteger(detailModel.getEndCardId()).subtract(new BigInteger(detailModel.getStartCardId())).intValueExact()+1; | |||||
if (obuNUm != cardNUm){ | |||||
throw new ManagerException("单片式OBU时,签的号段与卡的号段数量必须相同"); | |||||
} | |||||
if (StringUtils.isEmpty(detailModel.getStartCardId()) || StringUtils.isEmpty(detailModel.getEndCardId())){ | |||||
throw new ManagerException("单片式OBU时,卡的是的段号和结束段号必填"); | |||||
} | |||||
if (detailModel.getStartCardId().length() != 20 || detailModel.getEndCardId().length() != 20){ | |||||
throw new ManagerException("卡号长度必须为20"); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} |
@ApiModel(description = "入库申请响应") | @ApiModel(description = "入库申请响应") | ||||
@Getter | @Getter | ||||
@Setter | @Setter | ||||
public class InvwEnterApplyInfoApplyResponseDTO extends BaseModel { | |||||
public class InvwEnterApplyAddResponseDTO extends BaseModel { | |||||
private String id; | |||||
public InvwEnterApplyAddResponseDTO(String id) { | |||||
this.id = id; | |||||
} | |||||
} | } |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import javax.validation.constraints.NotBlank; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "取消入库请求") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyCancelRequestDTO extends AbstractBizRequestDTO { | |||||
@ApiModelProperty(value = "申请id") | |||||
@NotBlank | |||||
private String id; | |||||
@ApiModelProperty(value = "取消理由") | |||||
@NotBlank | |||||
private String reason; | |||||
} |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.common.model.BaseModel; | |||||
import io.swagger.annotations.ApiModel; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "取消入库响应") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyCancelResponseDTO extends BaseModel { | |||||
private String id; | |||||
public InvwEnterApplyCancelResponseDTO(String id) { | |||||
this.id = id; | |||||
} | |||||
} |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
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.InventoryType; | |||||
import cn.com.taiji.core.entity.dict.invw.OwnType; | |||||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||||
import cn.com.taiji.invw.model.enter.EnterApplyDetailModel; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import javax.persistence.EnumType; | |||||
import javax.persistence.Enumerated; | |||||
import javax.validation.constraints.NotBlank; | |||||
import javax.validation.constraints.NotNull; | |||||
import java.math.BigInteger; | |||||
import java.util.List; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "号段校验请求") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyCodeValidRequestDTO extends AbstractBizRequestDTO { | |||||
@ApiModelProperty(value = "库存类型:卡、签") | |||||
@NotNull | |||||
@Enumerated(EnumType.STRING) | |||||
private InventoryType inventoryType; | |||||
@ApiModelProperty(value = "卡类型") | |||||
@Enumerated(EnumType.STRING) | |||||
private CardType cardType; | |||||
@ApiModelProperty(value = "签类型") | |||||
@Enumerated(EnumType.STRING) | |||||
private ObuType obuType; | |||||
@ApiModelProperty(value = "起始-结束号段list") | |||||
@NotNull | |||||
private List<EnterApplyDetailModel> enterApplyDetailModels; | |||||
public void valid() throws ManagerException { | |||||
if (InventoryType.CARD.equals(inventoryType)){ | |||||
if (cardType == null){ | |||||
throw new ManagerException("未选择卡类型"); | |||||
} | |||||
for (EnterApplyDetailModel detailModel : enterApplyDetailModels) { | |||||
if (detailModel.getStartId().length() != 20 || detailModel.getEndId().length() != 20){ | |||||
throw new ManagerException("卡号长度必须为20"); | |||||
} | |||||
} | |||||
}else if (InventoryType.OBU.equals(inventoryType)){ | |||||
if (obuType == null){ | |||||
throw new ManagerException("未选择签类型"); | |||||
} | |||||
for (EnterApplyDetailModel detailModel : enterApplyDetailModels) { | |||||
if (StringUtils.isEmpty(detailModel.getStartId()) || StringUtils.isEmpty(detailModel.getEndId())){ | |||||
throw new ManagerException("起始或结束号段未填写完整"); | |||||
} | |||||
if (detailModel.getStartId().length() != 16 || detailModel.getEndId().length() != 16){ | |||||
throw new ManagerException("签号长度必须为16"); | |||||
} | |||||
} | |||||
if (ObuType.SINGLE_CHIP.equals(obuType)){ | |||||
if (cardType == null){ | |||||
throw new ManagerException("单片式OBU时,卡类型必填"); | |||||
} | |||||
for (EnterApplyDetailModel detailModel : enterApplyDetailModels) { | |||||
int obuNUm = new BigInteger(detailModel.getEndId()).subtract(new BigInteger(detailModel.getStartId())).intValueExact()+1; | |||||
int cardNUm = new BigInteger(detailModel.getEndCardId()).subtract(new BigInteger(detailModel.getStartCardId())).intValueExact()+1; | |||||
if (obuNUm != cardNUm){ | |||||
throw new ManagerException("单片式OBU时,签的号段与卡的号段数量必须相同"); | |||||
} | |||||
if (StringUtils.isEmpty(detailModel.getStartCardId()) || StringUtils.isEmpty(detailModel.getEndCardId())){ | |||||
throw new ManagerException("单片式OBU时,卡的是的段号和结束段号必填"); | |||||
} | |||||
if (detailModel.getStartCardId().length() != 20 || detailModel.getEndCardId().length() != 20){ | |||||
throw new ManagerException("卡号长度必须为20"); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.common.model.BaseModel; | |||||
import io.swagger.annotations.ApiModel; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "号段校验响应") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyCodeValidResponseDTO extends BaseModel { | |||||
private Boolean valid; | |||||
public InvwEnterApplyCodeValidResponseDTO(Boolean valid) { | |||||
this.valid = valid; | |||||
} | |||||
} |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
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.InventoryType; | |||||
import cn.com.taiji.core.entity.dict.invw.OwnType; | |||||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||||
import cn.com.taiji.invw.model.enter.EnterApplyDetailModel; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import javax.validation.constraints.NotBlank; | |||||
import javax.validation.constraints.NotNull; | |||||
import java.util.List; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "确认入库请求") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyConfirmRequestDTO extends AbstractBizRequestDTO { | |||||
@ApiModelProperty(value = "申请id") | |||||
@NotBlank | |||||
private String id; | |||||
} |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.common.model.BaseModel; | |||||
import io.swagger.annotations.ApiModel; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "确认入库响应") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyConfirmResponseDTO extends BaseModel { | |||||
private String id; | |||||
public InvwEnterApplyConfirmResponseDTO(String id) { | |||||
this.id = id; | |||||
} | |||||
} |
package cn.com.taiji.invw.dto.enter; | |||||
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.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 javax.persistence.Column; | |||||
import javax.validation.constraints.NotBlank; | |||||
import javax.validation.constraints.NotNull; | |||||
import javax.validation.constraints.Size; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "入库申请请求") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyInfoApplyRequestDTO extends AbstractBizRequestDTO { | |||||
@ApiModelProperty(value = "仓库编号") | |||||
@NotBlank | |||||
private String storeCode; | |||||
@ApiModelProperty(value = "库存类型:卡、签") | |||||
@NotNull | |||||
private InventoryType inventoryType; | |||||
@ApiModelProperty(value = "库存型号") | |||||
@NotNull | |||||
private DeviceVersion version; | |||||
@ApiModelProperty(value = "采购厂商") | |||||
@NotBlank | |||||
private String brand; | |||||
@ApiModelProperty(value = "卡类型") | |||||
private CardType cardType; | |||||
@ApiModelProperty(value = "签类型") | |||||
private ObuType obuType; | |||||
@ApiModelProperty(value = "单价") | |||||
private Long unitPrice; | |||||
@ApiModelProperty(value = "产权类型") | |||||
private OwnType ownType; | |||||
@ApiModelProperty(value = "一发系统号段申请批次号") | |||||
private String BatchNo; | |||||
@ApiModelProperty(value = "附件地址") | |||||
private String filePath; | |||||
} |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "入库申请查看详情请求") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyParseExcelRequestDTO extends AbstractBizRequestDTO { | |||||
@ApiModelProperty("excel的url") | |||||
private String excelUrl; | |||||
} |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.common.model.BaseModel; | |||||
import cn.com.taiji.invw.model.enter.EnterApplyDetailModel; | |||||
import io.swagger.annotations.ApiModel; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import java.util.List; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "入库申请查看详情响应") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyParseExcelResponseDTO extends BaseModel { | |||||
private List<EnterApplyDetailModel> list; | |||||
} |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
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.InventoryType; | |||||
import cn.com.taiji.core.entity.dict.invw.OwnType; | |||||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||||
import cn.com.taiji.invw.model.enter.EnterApplyDetailModel; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import javax.persistence.EnumType; | |||||
import javax.persistence.Enumerated; | |||||
import javax.validation.constraints.NotBlank; | |||||
import javax.validation.constraints.NotNull; | |||||
import java.math.BigInteger; | |||||
import java.util.List; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "入库申请修改信息请求") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyUpdateRequestDTO extends AbstractBizRequestDTO { | |||||
@ApiModelProperty(value = "申请id") | |||||
@NotBlank | |||||
private String id; | |||||
@ApiModelProperty(value = "仓库编号") | |||||
@NotBlank | |||||
private String storeCode; | |||||
@ApiModelProperty(value = "仓库渠道编号") | |||||
private String agencyId; | |||||
@ApiModelProperty(value = "库存类型:卡、签") | |||||
@NotNull | |||||
@Enumerated(EnumType.STRING) | |||||
private InventoryType inventoryType; | |||||
@ApiModelProperty(value = "库存型号") | |||||
@NotNull | |||||
@Enumerated(EnumType.STRING) | |||||
private DeviceVersion version; | |||||
@ApiModelProperty(value = "采购厂商") | |||||
@NotBlank | |||||
private String brand; | |||||
@ApiModelProperty(value = "卡类型") | |||||
@Enumerated(EnumType.STRING) | |||||
private CardType cardType; | |||||
@ApiModelProperty(value = "签类型") | |||||
@Enumerated(EnumType.STRING) | |||||
private ObuType obuType; | |||||
@ApiModelProperty(value = "单价") | |||||
private Long unitPrice; | |||||
@ApiModelProperty(value = "产权类型") | |||||
@NotNull | |||||
@Enumerated(EnumType.STRING) | |||||
private OwnType ownType; | |||||
@ApiModelProperty(value = "附件地址") | |||||
private String filePath; | |||||
@ApiModelProperty(value = "起始-结束号段list") | |||||
@NotNull | |||||
private List<EnterApplyDetailModel> enterApplyDetailModels; | |||||
public void valid() throws ManagerException { | |||||
if (InventoryType.CARD.equals(inventoryType)){ | |||||
if (cardType == null){ | |||||
throw new ManagerException("未选择卡类型"); | |||||
} | |||||
for (EnterApplyDetailModel detailModel : enterApplyDetailModels) { | |||||
if (detailModel.getStartId().length() != 20 || detailModel.getEndId().length() != 20){ | |||||
throw new ManagerException("卡号长度必须为20"); | |||||
} | |||||
} | |||||
}else if (InventoryType.OBU.equals(inventoryType)){ | |||||
if (obuType == null){ | |||||
throw new ManagerException("未选择签类型"); | |||||
} | |||||
for (EnterApplyDetailModel detailModel : enterApplyDetailModels) { | |||||
if (StringUtils.isEmpty(detailModel.getStartId()) || StringUtils.isEmpty(detailModel.getEndId())){ | |||||
throw new ManagerException("起始或结束号段未填写完整"); | |||||
} | |||||
if (detailModel.getStartId().length() != 16 || detailModel.getEndId().length() != 16){ | |||||
throw new ManagerException("卡号长度必须为16"); | |||||
} | |||||
} | |||||
if (ObuType.SINGLE_CHIP.equals(obuType)){ | |||||
if (cardType == null){ | |||||
throw new ManagerException("单片式OBU时,卡类型必填"); | |||||
} | |||||
for (EnterApplyDetailModel detailModel : enterApplyDetailModels) { | |||||
int obuNUm = new BigInteger(detailModel.getEndId()).subtract(new BigInteger(detailModel.getStartId())).intValueExact()+1; | |||||
int cardNUm = new BigInteger(detailModel.getEndCardId()).subtract(new BigInteger(detailModel.getStartCardId())).intValueExact()+1; | |||||
if (obuNUm != cardNUm){ | |||||
throw new ManagerException("单片式OBU时,签的号段与卡的号段数量必须相同"); | |||||
} | |||||
if (StringUtils.isEmpty(detailModel.getStartCardId()) || StringUtils.isEmpty(detailModel.getEndCardId())){ | |||||
throw new ManagerException("单片式OBU时,卡的是的段号和结束段号必填"); | |||||
} | |||||
if (detailModel.getStartCardId().length() != 20 || detailModel.getEndCardId().length() != 20){ | |||||
throw new ManagerException("卡号长度必须为20"); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.common.model.BaseModel; | |||||
import io.swagger.annotations.ApiModel; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "入库申请修改信息响应") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyUpdateResponseDTO extends BaseModel { | |||||
private String id; | |||||
public InvwEnterApplyUpdateResponseDTO(String id) { | |||||
this.id = id; | |||||
} | |||||
} |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
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.InventoryType; | |||||
import cn.com.taiji.core.entity.dict.invw.OwnType; | |||||
import cn.com.taiji.invw.dto.AbstractBizRequestDTO; | |||||
import cn.com.taiji.invw.model.enter.EnterApplyDetailModel; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import javax.validation.constraints.NotBlank; | |||||
import javax.validation.constraints.NotNull; | |||||
import java.util.List; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "入库申请查看详情请求") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyViewRequestDTO extends AbstractBizRequestDTO { | |||||
@ApiModelProperty("申请id") | |||||
private String id; | |||||
} |
package cn.com.taiji.invw.dto.enter; | |||||
import cn.com.taiji.common.model.BaseModel; | |||||
import cn.com.taiji.core.entity.invw.InvwEnterApply; | |||||
import cn.com.taiji.core.entity.invw.InvwEnterApplyDetails; | |||||
import io.swagger.annotations.ApiModel; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import java.util.List; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/19 16:59 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@ApiModel(description = "入库申请查看详情响应") | |||||
@Getter | |||||
@Setter | |||||
public class InvwEnterApplyViewResponseDTO extends BaseModel { | |||||
private InvwEnterApply enterApply; | |||||
private List<InvwEnterApplyDetails> applyDetailsList; | |||||
public InvwEnterApplyViewResponseDTO(InvwEnterApply enterApply, List<InvwEnterApplyDetails> applyDetailsList){ | |||||
this.enterApply = enterApply; | |||||
this.applyDetailsList = applyDetailsList; | |||||
} | |||||
} |
package cn.com.taiji.core.manager.comm; | |||||
package cn.com.taiji.invw.manager; | |||||
import cn.com.taiji.common.pub.IPTools; | import cn.com.taiji.common.pub.IPTools; | ||||
import cn.com.taiji.common.pub.TimeTools; | import cn.com.taiji.common.pub.TimeTools; | ||||
import cn.com.taiji.core.repo.jpa.log.OperateLogRepo; | import cn.com.taiji.core.repo.jpa.log.OperateLogRepo; | ||||
import cn.com.taiji.core.repo.jpa.user.AccountInfoRepo; | import cn.com.taiji.core.repo.jpa.user.AccountInfoRepo; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | |||||
import org.springframework.web.context.request.RequestContextHolder; | import org.springframework.web.context.request.RequestContextHolder; | ||||
import org.springframework.web.context.request.ServletRequestAttributes; | import org.springframework.web.context.request.ServletRequestAttributes; | ||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.util.Optional; | |||||
/** | /** | ||||
* @Auther: humh | * @Auther: humh | ||||
* @Description: | * @Description: | ||||
* @Date: 2025/5/19 17:15 | |||||
* @Date: 2025/5/22 15:32 | |||||
* @email: huminghao@mail.taiji.com.cn | * @email: huminghao@mail.taiji.com.cn | ||||
* @version: 1.0 | * @version: 1.0 | ||||
*/ | */ | ||||
@Service | |||||
public class OperateLogManagerImpl implements OperateLogManager{ | |||||
public abstract class AbstractInvwManager extends AbstractCommManager{ | |||||
@Autowired | @Autowired | ||||
private OperateLogRepo operateLogRepo; | private OperateLogRepo operateLogRepo; | ||||
private AccountInfoRepo accountInfoRepo; | private AccountInfoRepo accountInfoRepo; | ||||
// 操作日志记录 | // 操作日志记录 | ||||
@Override | |||||
public void persistOperateLog(OperateType operateType, String operatorDataId, SourceType source, | |||||
String openId, String msg, String ip) { | |||||
saveOperateLog(operateType, operatorDataId, source, openId, getAccountName(openId,null), msg, ip); | |||||
protected void persistOperateLog(OperateType operateType, String operatorDataId, SourceType source, | |||||
String openId, String msg) { | |||||
saveOperateLog(operateType, operatorDataId, source, openId, getAccountName(openId), msg); | |||||
} | } | ||||
private void saveOperateLog(OperateType operateType, String dataId, SourceType source, String openId, | |||||
String operatorName, String msg, String ip) { | |||||
protected void saveOperateLog(OperateType operateType, String dataId, SourceType source, String openId, | |||||
String operatorName, String msg) { | |||||
HttpServletRequest request = | |||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
String ip = IPTools.getIpAddr(request); | |||||
LocalDateTime now = LocalDateTime.now(); | LocalDateTime now = LocalDateTime.now(); | ||||
OperateLog log = new OperateLog(); | OperateLog log = new OperateLog(); | ||||
log.setPartKey(Long.valueOf(now.format(TimeTools.yyyyMM))); | log.setPartKey(Long.valueOf(now.format(TimeTools.yyyyMM))); | ||||
operateLogRepo.persist(log); | operateLogRepo.persist(log); | ||||
} | } | ||||
private String getAccountName(String openId, String defaultName) { | |||||
return Optional.ofNullable(getAccountInfo(openId)).map(AccountInfo::getUserName).orElse(defaultName); | |||||
protected String getAccountName(String openId) { | |||||
return getAccountInfo(openId).getUserName(); | |||||
} | } | ||||
private AccountInfo getAccountInfo(String openId) { | |||||
protected AccountInfo getAccountInfo(String openId) { | |||||
if (openId == null) { | if (openId == null) { | ||||
return null; | return null; | ||||
} | } | ||||
return accountInfoRepo.findByOpenId(openId); | return accountInfoRepo.findByOpenId(openId); | ||||
} | } | ||||
} | } |
package cn.com.taiji.invw.manager.enter; | package cn.com.taiji.invw.manager.enter; | ||||
import cn.com.taiji.common.manager.ManagerException; | |||||
import cn.com.taiji.common.model.dao.Pagination; | import cn.com.taiji.common.model.dao.Pagination; | ||||
import cn.com.taiji.invw.dto.enter.InvwEnterApplyInfoApplyRequestDTO; | |||||
import cn.com.taiji.invw.dto.enter.InvwEnterApplyInfoApplyResponseDTO; | |||||
import cn.com.taiji.invw.dto.enter.InvwEnterApplyPageRequestDTO; | |||||
import cn.com.taiji.invw.dto.enter.*; | |||||
/** | /** | ||||
* @Auther: humh | * @Auther: humh | ||||
Pagination page(InvwEnterApplyPageRequestDTO req); | Pagination page(InvwEnterApplyPageRequestDTO req); | ||||
InvwEnterApplyInfoApplyResponseDTO apply(InvwEnterApplyInfoApplyRequestDTO dto); | |||||
InvwEnterApplyAddResponseDTO apply(InvwEnterApplyAddRequestDTO dto) throws ManagerException; | |||||
InvwEnterApplyUpdateResponseDTO update(InvwEnterApplyUpdateRequestDTO dto) throws ManagerException; | |||||
InvwEnterApplyConfirmResponseDTO confirm(InvwEnterApplyConfirmRequestDTO dto) throws ManagerException; | |||||
InvwEnterApplyViewResponseDTO view(InvwEnterApplyViewRequestDTO dto); | |||||
InvwEnterApplyCancelResponseDTO cancel(InvwEnterApplyCancelRequestDTO dto); | |||||
InvwEnterApplyCodeValidResponseDTO codeValid(InvwEnterApplyCodeValidRequestDTO dto) throws ManagerException; | |||||
InvwEnterApplyParseExcelResponseDTO parseExcel(InvwEnterApplyParseExcelRequestDTO dto); | |||||
} | } |
package cn.com.taiji.invw.manager.enter; | package cn.com.taiji.invw.manager.enter; | ||||
import cn.com.taiji.common.manager.ManagerException; | |||||
import cn.com.taiji.common.model.dao.Pagination; | import cn.com.taiji.common.model.dao.Pagination; | ||||
import cn.com.taiji.core.manager.comm.OperateLogManager; | |||||
import cn.com.taiji.core.manager.comm.OperateLogManagerImpl; | |||||
import cn.com.taiji.common.pub.BeanTools; | |||||
import cn.com.taiji.common.pub.CollectionTools; | |||||
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.InvDeviceStatus; | |||||
import cn.com.taiji.core.entity.dict.invw.InventoryType; | |||||
import cn.com.taiji.core.entity.dict.log.OperateType; | |||||
import cn.com.taiji.core.entity.invw.InvwCardDetails; | |||||
import cn.com.taiji.core.entity.invw.InvwEnterApply; | |||||
import cn.com.taiji.core.entity.invw.InvwEnterApplyDetails; | |||||
import cn.com.taiji.core.entity.invw.InvwObuDetails; | |||||
import cn.com.taiji.core.repo.jpa.invw.InvwCardDetailsRepo; | |||||
import cn.com.taiji.core.repo.jpa.invw.InvwEnterApplyDetailsRepo; | |||||
import cn.com.taiji.core.repo.jpa.invw.InvwEnterApplyRepo; | import cn.com.taiji.core.repo.jpa.invw.InvwEnterApplyRepo; | ||||
import cn.com.taiji.core.repo.jpa.invw.InvwObuDetailsRepo; | |||||
import cn.com.taiji.core.repo.request.invw.InvwEnterApplyPageRequest; | import cn.com.taiji.core.repo.request.invw.InvwEnterApplyPageRequest; | ||||
import cn.com.taiji.invw.dto.enter.InvwEnterApplyInfoApplyRequestDTO; | |||||
import cn.com.taiji.invw.dto.enter.InvwEnterApplyInfoApplyResponseDTO; | |||||
import cn.com.taiji.invw.dto.enter.InvwEnterApplyPageRequestDTO; | |||||
import cn.com.taiji.invw.manager.AbstractCommManager; | |||||
import cn.com.taiji.invw.dto.enter.*; | |||||
import cn.com.taiji.invw.manager.AbstractInvwManager; | |||||
import cn.com.taiji.invw.model.enter.EnterApplyDetailModel; | |||||
import cn.com.taiji.invw.tools.GenerateNoUtil; | |||||
import cn.com.taiji.invw.tools.SourceTargetMapper; | |||||
import com.alibaba.excel.EasyExcel; | |||||
import org.apache.commons.compress.utils.Lists; | |||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import org.springframework.transaction.annotation.Transactional; | |||||
import java.io.File; | |||||
import java.math.BigInteger; | |||||
import java.time.LocalDateTime; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
/** | /** | ||||
* @Auther: humh | * @Auther: humh | ||||
* @version: 1.0 | * @version: 1.0 | ||||
*/ | */ | ||||
@Service | @Service | ||||
public class InvwEnterApplyManagerImpl extends AbstractCommManager implements InvwEnterApplyManager { | |||||
public class InvwEnterApplyManagerImpl extends AbstractInvwManager implements InvwEnterApplyManager { | |||||
@Autowired | @Autowired | ||||
private InvwEnterApplyRepo repo; | private InvwEnterApplyRepo repo; | ||||
@Autowired | @Autowired | ||||
private OperateLogManager operateLogManager; | |||||
private InvwEnterApplyDetailsRepo applyDetailsRepo; | |||||
@Autowired | |||||
private InvwCardDetailsRepo cardDetailsRepo; | |||||
@Autowired | |||||
private InvwObuDetailsRepo obuDetailsRepo; | |||||
@Override | @Override | ||||
public Pagination page(InvwEnterApplyPageRequestDTO req) { | public Pagination page(InvwEnterApplyPageRequestDTO req) { | ||||
InvwEnterApplyPageRequest pageRequest = copyProperties(req, new InvwEnterApplyPageRequest()); | InvwEnterApplyPageRequest pageRequest = copyProperties(req, new InvwEnterApplyPageRequest()); | ||||
return repo.page(pageRequest); | return repo.page(pageRequest); | ||||
} | } | ||||
@Override | @Override | ||||
public InvwEnterApplyInfoApplyResponseDTO apply(InvwEnterApplyInfoApplyRequestDTO dto) { | |||||
@Transactional(rollbackFor = Exception.class) | |||||
public InvwEnterApplyAddResponseDTO apply(InvwEnterApplyAddRequestDTO dto) throws ManagerException { | |||||
dto.valid(); | |||||
//起始号段、结束号段做校验 | |||||
startIdAndEndIdValid(dto.getInventoryType(), dto.getObuType(), dto.getEnterApplyDetailModels()); | |||||
//申请入库 | |||||
InvwEnterApply enterApply = copyProperties(dto, new InvwEnterApply()); | |||||
enterApply.setApplyNo(GenerateNoUtil.generateApplyNo()); | |||||
//获取总价,统计数量*单价 | |||||
int sum = dto.getEnterApplyDetailModels().stream().mapToInt(o -> new BigInteger(o.getEndId()).subtract(new BigInteger(o.getStartId())).intValueExact()+1).sum(); | |||||
enterApply.setApplyCount(sum); | |||||
enterApply.setTotalPrice(sum * enterApply.getUnitPrice()); | |||||
LocalDateTime now = LocalDateTime.now(); | |||||
enterApply.setApplyTime(now); | |||||
enterApply.setInsertTime(now); | |||||
enterApply.setApplyStatus(InvApplyStatus.NEW); | |||||
repo.save(enterApply); | |||||
//插入明细表,通过代理对象调用子方法,确保事务拦截器生效(避免同类内部调用绕过代理的问题) | |||||
addInventoryApplyDetail(dto.getEnterApplyDetailModels(), enterApply); | |||||
persistOperateLog(OperateType.ENTER_APPLY, enterApply.getId(), dto.getOrderSource(), dto.getOpenId(), "入库申请"); | |||||
return new InvwEnterApplyAddResponseDTO(enterApply.getId()); | |||||
} | |||||
@Override | |||||
@Transactional(rollbackFor = Exception.class) | |||||
public InvwEnterApplyUpdateResponseDTO update(InvwEnterApplyUpdateRequestDTO dto) throws ManagerException { | |||||
dto.valid(); | |||||
//起始号段、结束号段做校验 | |||||
startIdAndEndIdValid(dto.getInventoryType(), dto.getObuType(), dto.getEnterApplyDetailModels()); | |||||
//申请入库 | |||||
InvwEnterApply enterApply = repo.findById(dto.getId()).orElse(null); | |||||
BeanTools.copyProperties(dto, enterApply); | |||||
//获取总价,统计数量*单价 | |||||
int sum = dto.getEnterApplyDetailModels().stream().mapToInt(o -> new BigInteger(o.getEndId()).subtract(new BigInteger(o.getStartId())).intValueExact()+1).sum(); | |||||
enterApply.setApplyCount(sum); | |||||
enterApply.setTotalPrice(sum * enterApply.getUnitPrice()); | |||||
LocalDateTime now = LocalDateTime.now(); | |||||
enterApply.setApplyTime(now); | |||||
enterApply.setInsertTime(now); | |||||
enterApply.setApplyStatus(InvApplyStatus.NEW); | |||||
repo.merge(enterApply); | |||||
//插入明细表及检查结果表,通过代理对象调用子方法,确保事务拦截器生效(避免同类内部调用绕过代理的问题) | |||||
updateInventoryApplyDetail(dto.getEnterApplyDetailModels(), enterApply); | |||||
persistOperateLog(OperateType.UPDATE_ENTER_APPLY, enterApply.getId(), dto.getOrderSource(), dto.getOpenId(), "入库申请修改"); | |||||
return new InvwEnterApplyUpdateResponseDTO(enterApply.getId()); | |||||
} | |||||
@Override | |||||
@Transactional(rollbackFor = Exception.class) | |||||
public InvwEnterApplyConfirmResponseDTO confirm(InvwEnterApplyConfirmRequestDTO dto) throws ManagerException { | |||||
InvwEnterApply enterApply = repo.findById(dto.getId()).orElse(null); | |||||
List<InvwEnterApplyDetails> detailsList = applyDetailsRepo.queryByApplyNo(enterApply.getApplyNo()); | |||||
//再次校验号段 | |||||
startIdAndEndIdValid(enterApply.getInventoryType(),enterApply.getObuType(),SourceTargetMapper.INSTANCE.enterToApplyDetailsListModel(detailsList)); | |||||
//进行入库处理,通过代理对象调用子方法,确保事务拦截器生效(避免同类内部调用绕过代理的问题) | |||||
LocalDateTime now = LocalDateTime.now(); | |||||
addCardAndObuDetails(enterApply, detailsList, now); | |||||
//更新状态 | |||||
enterApply.setSureTime(now); | |||||
enterApply.setApplyStatus(InvApplyStatus.COMFIRE); | |||||
repo.merge(enterApply); | |||||
persistOperateLog(OperateType.CONFIRM_ENTER_APPLY, enterApply.getId(), dto.getOrderSource(), dto.getOpenId(), "确认入库"); | |||||
return new InvwEnterApplyConfirmResponseDTO(dto.getId()); | |||||
} | |||||
@Override | |||||
public InvwEnterApplyViewResponseDTO view(InvwEnterApplyViewRequestDTO dto) { | |||||
InvwEnterApply enterApply = repo.findById(dto.getId()).orElse(null); | |||||
List<InvwEnterApplyDetails> applyDetailsList = applyDetailsRepo.queryByApplyNo(enterApply.getApplyNo()); | |||||
return new InvwEnterApplyViewResponseDTO(enterApply, applyDetailsList); | |||||
} | |||||
@Override | |||||
@Transactional(rollbackFor = Exception.class) | |||||
public InvwEnterApplyCancelResponseDTO cancel(InvwEnterApplyCancelRequestDTO dto) { | |||||
InvwEnterApply enterApply = repo.findById(dto.getId()).orElse(null); | |||||
enterApply.setApplyStatus(InvApplyStatus.REJECT); | |||||
enterApply.setReason(dto.getReason()); | |||||
repo.merge(enterApply); | |||||
persistOperateLog(OperateType.CANCEL_ENTER_APPLY, enterApply.getId(), dto.getOrderSource(), dto.getOpenId(), "取消入库"); | |||||
return new InvwEnterApplyCancelResponseDTO(dto.getId()); | |||||
} | |||||
@Override | |||||
public InvwEnterApplyCodeValidResponseDTO codeValid(InvwEnterApplyCodeValidRequestDTO dto) throws ManagerException { | |||||
dto.valid(); | |||||
//校验 | |||||
startIdAndEndIdValid(dto.getInventoryType(),dto.getObuType(),dto.getEnterApplyDetailModels()); | |||||
return new InvwEnterApplyCodeValidResponseDTO(true); | |||||
} | |||||
@Override | |||||
public InvwEnterApplyParseExcelResponseDTO parseExcel(InvwEnterApplyParseExcelRequestDTO dto) { | |||||
operateLogManager.persistOperateLog(null,"",null,"","",""); | |||||
return null; | return null; | ||||
} | } | ||||
public void addCardAndObuDetails(InvwEnterApply enterApply, List<InvwEnterApplyDetails> detailsList, LocalDateTime now) { | |||||
if (InventoryType.CARD.equals(enterApply.getInventoryType())) { | |||||
ArrayList<InvwCardDetails> cardList = Lists.newArrayList(); | |||||
for (InvwEnterApplyDetails applyDetails : detailsList) { | |||||
for (int i = 0; i < new BigInteger(applyDetails.getEndId()).subtract(new BigInteger(applyDetails.getStartId())).intValueExact()+1; i++) { | |||||
InvwCardDetails cardDetails = copyProperties(enterApply, new InvwCardDetails(), "id", "insertTime"); | |||||
cardDetails.setOrderNo(enterApply.getApplyNo()); | |||||
cardDetails.setInsertTime(now); | |||||
cardDetails.setCardId(new BigInteger(applyDetails.getStartId()).add(BigInteger.valueOf(i)).toString()); | |||||
cardDetails.setStatus(InvDeviceStatus.NEW); | |||||
cardList.add(cardDetails); | |||||
} | |||||
} | |||||
cardDetailsRepo.saveAll(cardList); | |||||
}else if (InventoryType.OBU.equals(enterApply.getInventoryType())) { | |||||
ArrayList<InvwObuDetails> obuList = Lists.newArrayList(); | |||||
for (InvwEnterApplyDetails applyDetails : detailsList) { | |||||
for (int i = 0; i < new BigInteger(applyDetails.getEndId()).subtract(new BigInteger(applyDetails.getStartId())).intValueExact()+1; i++) { | |||||
InvwObuDetails obuDetails = copyProperties(enterApply, new InvwObuDetails(), "id", "insertTime"); | |||||
obuDetails.setInsertTime(now); | |||||
obuDetails.setOrderNo(enterApply.getApplyNo()); | |||||
obuDetails.setObuId(new BigInteger(applyDetails.getStartId()).add(BigInteger.valueOf(i)).toString()); | |||||
obuDetails.setCardId(new BigInteger(applyDetails.getStartCardId()).add(BigInteger.valueOf(i)).toString()); | |||||
obuDetails.setStatus(InvDeviceStatus.NEW); | |||||
obuList.add(obuDetails); | |||||
} | |||||
} | |||||
obuDetailsRepo.saveAll(obuList); | |||||
//OBU单片式处理card | |||||
if (ObuType.SINGLE_CHIP.equals(enterApply.getObuType())){ | |||||
ArrayList<InvwCardDetails> cardList = Lists.newArrayList(); | |||||
for (InvwEnterApplyDetails applyDetails : detailsList) { | |||||
for (int i = 0; i < new BigInteger(applyDetails.getEndCardId()).subtract(new BigInteger(applyDetails.getStartCardId())).intValueExact()+1; i++) { | |||||
InvwCardDetails cardDetails = copyProperties(enterApply, new InvwCardDetails(), "id", "insertTime"); | |||||
cardDetails.setInsertTime(now); | |||||
cardDetails.setOrderNo(enterApply.getApplyNo()); | |||||
cardDetails.setStatus(InvDeviceStatus.NEW); | |||||
cardDetails.setCardId(new BigInteger(applyDetails.getStartCardId()).add(BigInteger.valueOf(i)).toString()); | |||||
cardList.add(cardDetails); | |||||
} | |||||
} | |||||
cardDetailsRepo.saveAll(cardList); | |||||
} | |||||
} | |||||
} | |||||
private void updateInventoryApplyDetail(List<EnterApplyDetailModel> detailModels, InvwEnterApply enterApply) throws ManagerException { | |||||
applyDetailsRepo.deleteByApplyNo(enterApply.getApplyNo()); | |||||
addInventoryApplyDetail(detailModels, enterApply); | |||||
} | |||||
/** | |||||
* 入库申请明细 | |||||
* | |||||
* @param detailModels | |||||
* @param enterApply | |||||
*/ | |||||
@Transactional | |||||
private void addInventoryApplyDetail(List<EnterApplyDetailModel> detailModels, InvwEnterApply enterApply) { | |||||
//保存数据明细数据 | |||||
List<InvwEnterApplyDetails> applyDetailEntity = SourceTargetMapper.INSTANCE.modelListToEnterApplyDetailsList(detailModels); | |||||
applyDetailEntity.forEach(s -> { | |||||
s.setApplyNo(enterApply.getApplyNo()); | |||||
s.setInsertTime(enterApply.getInsertTime()); | |||||
}); | |||||
applyDetailsRepo.saveAll(applyDetailEntity); | |||||
} | |||||
/** | |||||
* @return | |||||
* @author: humh | |||||
* @description: 起始、结束段号校验 | |||||
* @date: 2025/5/21 15:40 | |||||
*/ | |||||
private void startIdAndEndIdValid(InventoryType inventoryType, ObuType obuType, List<EnterApplyDetailModel> detailModels) throws ManagerException { | |||||
if (InventoryType.CARD.equals(inventoryType)) { | |||||
for (EnterApplyDetailModel detailModel : detailModels) { | |||||
List<InvwCardDetails> detailsList = cardDetailsRepo.queryByCardIdBetween(detailModel.getStartId(), detailModel.getEndId()); | |||||
if (!CollectionTools.isEmpty(detailsList)) { | |||||
throw new ManagerException("卡号段已存在!"); | |||||
} | |||||
} | |||||
} else if (InventoryType.OBU.equals(inventoryType)) { | |||||
if (ObuType.SINGLE_CHIP.equals(obuType)) { | |||||
for (EnterApplyDetailModel detailModel : detailModels) { | |||||
List<InvwCardDetails> detailsList = cardDetailsRepo.queryByCardIdBetween(detailModel.getStartCardId(), detailModel.getEndCardId()); | |||||
if (!CollectionTools.isEmpty(detailsList)) { | |||||
throw new ManagerException("卡号段已存在!"); | |||||
} | |||||
} | |||||
} | |||||
for (EnterApplyDetailModel detailModel : detailModels) { | |||||
List<InvwObuDetails> detailsList = obuDetailsRepo.queryByObuIdBetween(detailModel.getStartId(), detailModel.getEndId()); | |||||
if (!CollectionTools.isEmpty(detailsList)) { | |||||
throw new ManagerException("签号段已存在!"); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } |
package cn.com.taiji.invw.model.enter; | |||||
import cn.com.taiji.common.model.BaseModel; | |||||
import com.alibaba.excel.annotation.ExcelProperty; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/21 10:44 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@Getter | |||||
@Setter | |||||
public class EnterApplyDetailModel extends BaseModel { | |||||
@ExcelProperty(index = 1) | |||||
private String startId; //起始编码 | |||||
@ExcelProperty(index = 2) | |||||
private String endId; //结束编码 | |||||
@ExcelProperty(index = 3) | |||||
private String startCardId;//单片式OBU时有值 | |||||
@ExcelProperty(index = 4) | |||||
private String endCardId;//单片式OBU时有值 | |||||
} |
package cn.com.taiji.invw.tools; | |||||
import cn.com.taiji.core.entity.invw.InvwEnterApplyDetails; | |||||
import cn.com.taiji.invw.model.enter.EnterApplyDetailModel; | |||||
import org.mapstruct.Mapper; | |||||
import org.mapstruct.ReportingPolicy; | |||||
import org.mapstruct.factory.Mappers; | |||||
import java.util.List; | |||||
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE) | |||||
public interface SourceTargetMapper { | |||||
/** 通行流水 字段数量类型相同,数量少:仅能让多的转换成少的,故没有toEntity*/ | |||||
SourceTargetMapper INSTANCE = Mappers.getMapper(SourceTargetMapper.class); | |||||
List<InvwEnterApplyDetails> modelListToEnterApplyDetailsList(List<EnterApplyDetailModel> model); | |||||
List<EnterApplyDetailModel> enterToApplyDetailsListModel(List<InvwEnterApplyDetails> entity); | |||||
} |
refresh: true | refresh: true | ||||
- data-id: comm-client.yaml | - data-id: comm-client.yaml | ||||
refresh: true | refresh: true | ||||
- data-id: minio-client.yaml | |||||
refresh: true | |||||
server: | server: | ||||
port: 9085 | port: 9085 | ||||
servlet: | servlet: |