|
|
@@ -358,6 +358,193 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public TradingBox addRent(TradingBox tradingBox) {
|
|
|
+ //判断id是否为空
|
|
|
+ if (tradingBox.getId() == null) {
|
|
|
+ //获取系统编号
|
|
|
+ R billNo = serialClient.getBillNo(tradingBox.getType(), "BOX", tradingBox.getType());
|
|
|
+ if (!billNo.isSuccess()) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ throw new Error("生成系统编号失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ tradingBox.setSysNo(billNo.getData().toString());
|
|
|
+ tradingBox.setCreateTime(new Date());
|
|
|
+ tradingBox.setCreateUser(AuthUtil.getUserId());
|
|
|
+ tradingBox.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ tradingBox.setTenantId(AuthUtil.getTenantId());
|
|
|
+ tradingBox.setStatus(0);
|
|
|
+ baseMapper.insert(tradingBox);
|
|
|
+ } else {
|
|
|
+ tradingBox.setUpdateTime(new Date());
|
|
|
+ tradingBox.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBox.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ baseMapper.updateById(tradingBox);
|
|
|
+ }
|
|
|
+ //明细数据
|
|
|
+ List<TradingBoxItem> tradingBoxItemList = tradingBox.getTradingBoxItemsList();
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxItemList) && tradingBoxItemList.size() > 0) {
|
|
|
+ for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
+ if (tradingBoxItem.getId() == null) {
|
|
|
+ tradingBoxItem.setCreateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem.setCreateTime(new Date());
|
|
|
+ tradingBoxItem.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ tradingBoxItem.setTenantId(AuthUtil.getTenantId());
|
|
|
+ tradingBoxItem.setPid(tradingBox.getId());
|
|
|
+ tradingBoxItemMapper.insert(tradingBoxItem);
|
|
|
+ } else {
|
|
|
+ tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem.setUpdateTime(new Date());
|
|
|
+ tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ tradingBoxItem.setPid(tradingBox.getId());
|
|
|
+ tradingBoxItemMapper.updateById(tradingBoxItem);
|
|
|
+ }
|
|
|
+ //明细图片
|
|
|
+ List<TradingBoxFiles> tradingBoxItemFilesList = tradingBoxItem.getTradingBoxFilesList();
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxItemFilesList) && tradingBoxItemFilesList.size() > 0) {
|
|
|
+ for (TradingBoxFiles tradingBoxFiles : tradingBoxItemFilesList) {
|
|
|
+ if (tradingBoxFiles.getId() == null) {
|
|
|
+ tradingBoxFiles.setCreateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxFiles.setCreateTime(new Date());
|
|
|
+ tradingBoxFiles.setTenantId(AuthUtil.getTenantId());
|
|
|
+ tradingBoxFiles.setPid(tradingBoxItem.getId());
|
|
|
+ tradingBoxFiles.setType("2");
|
|
|
+ tradingBoxFiles.setFileName(tradingBoxFiles.getLabel());
|
|
|
+ tradingBoxFiles.setUrl(tradingBoxFiles.getValue());
|
|
|
+ tradingBoxFilesMapper.insert(tradingBoxFiles);
|
|
|
+ } else {
|
|
|
+ tradingBoxFiles.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxFiles.setUpdateTime(new Date());
|
|
|
+ tradingBoxFiles.setPid(tradingBoxItem.getId());
|
|
|
+ tradingBoxFiles.setType("2");
|
|
|
+ tradingBoxFiles.setFileName(tradingBoxFiles.getLabel());
|
|
|
+ tradingBoxFiles.setUrl(tradingBoxFiles.getValue());
|
|
|
+ tradingBoxFilesMapper.updateById(tradingBoxFiles);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tradingBoxItem.setTradingBoxFilesList(tradingBoxItemFilesList);
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxItem.getCode())) {
|
|
|
+ //更新箱档案信息
|
|
|
+ Archives archivesR = archivesMapper.selectOne(new LambdaQueryWrapper<Archives>().eq(Archives::getIsDeleted, 0).eq(Archives::getTenantId, AuthUtil.getTenantId()).eq(Archives::getCode, tradingBoxItem.getCode()));
|
|
|
+ Archives archives = new Archives();
|
|
|
+ if (ObjectUtils.isNotNull(archivesR)) {
|
|
|
+ BeanUtil.copy(archivesR, archives);
|
|
|
+ }
|
|
|
+ archives.setCode(tradingBoxItem.getCode());
|
|
|
+ archives.setName(tradingBoxItem.getBoxType());
|
|
|
+ archives.setVolume(tradingBoxItem.getVolume());
|
|
|
+ archives.setGorssWeight(tradingBoxItem.getGrossWeight());
|
|
|
+ archives.setStatus(tradingBoxItem.getStatus());
|
|
|
+ archives.setTypeId(tradingBoxItem.getBoxTypeId());
|
|
|
+ archives.setAddressId(tradingBoxItem.getAddressId());
|
|
|
+ archives.setAddress(tradingBoxItem.getAddress());
|
|
|
+ archives.setNewDate(tradingBoxItem.getNewDate());
|
|
|
+ archives.setLeasingCompanyId(tradingBox.getPurchaseCompanyId());
|
|
|
+ archives.setLeasingCompany(tradingBox.getPurchaseCompanyName());
|
|
|
+ archives.setBoxSource(tradingBoxItem.getBoxSource());
|
|
|
+ archives.setBoxStatus(tradingBoxItem.getBoxStatus());
|
|
|
+ archives.setEmptyWeight(tradingBoxItem.getEmptyWeight());
|
|
|
+ archives.setTare(tradingBoxItem.getTare());
|
|
|
+ archives.setLoadingWeight(tradingBoxItem.getLoadingWeight());
|
|
|
+ archives.setBoxMakingCompany(tradingBoxItem.getBoxMakingCompany());
|
|
|
+ archives.setBoxMakingCompanyId(tradingBoxItem.getBoxMakingCompanyId());
|
|
|
+ archives.setBoxMakingDate(tradingBoxItem.getBoxMakingDate());
|
|
|
+ archives.setLeaseCommencementDate(tradingBoxItem.getLeaseCommencementDate());
|
|
|
+ archives.setBoxAge(tradingBoxItem.getBoxAge());
|
|
|
+ archives.setPurchaseDate(tradingBox.getPurchaseDate());
|
|
|
+ archives.setContractNo(tradingBox.getContractNo());
|
|
|
+ if (ObjectUtils.isNotNull(archivesR)) {
|
|
|
+ archives.setUpdateTime(new Date());
|
|
|
+ archives.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ archives.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ archivesMapper.updateById(archives);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ archives.setCreateUser(AuthUtil.getUserId());
|
|
|
+ archives.setCreateTime(new Date());
|
|
|
+ archives.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ archives.setTenantId(AuthUtil.getTenantId());
|
|
|
+ archivesMapper.insert(archives);
|
|
|
+ List<ArchivesFiles> archivesFilesList = BeanUtil.copy(tradingBoxItem.getTradingBoxFilesList(), ArchivesFiles.class);
|
|
|
+ for (ArchivesFiles archivesFiles : archivesFilesList) {
|
|
|
+ archivesFiles.setId(null);
|
|
|
+ archivesFiles.setPid(archives.getId());
|
|
|
+ archivesFiles.setFileName(archivesFiles.getLabel());
|
|
|
+ archivesFiles.setUrl(archivesFiles.getValue());
|
|
|
+ archivesFiles.setCreateUser(AuthUtil.getUserId());
|
|
|
+ archivesFiles.setCreateTime(new Date());
|
|
|
+ archivesFilesMapper.insert(archivesFiles);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //记录箱轨迹信息
|
|
|
+ ArchivesTrajectory archivesTrajectory = new ArchivesTrajectory();
|
|
|
+ if ("ZR".equals(tradingBox.getType())) {
|
|
|
+ archivesTrajectory.setStatus("租入");
|
|
|
+ } else if ("ZC".equals(tradingBox.getType())) {
|
|
|
+ archivesTrajectory.setStatus("租出");
|
|
|
+ }
|
|
|
+ archivesTrajectory.setContractNo(tradingBox.getContractNo());
|
|
|
+ archivesTrajectory.setBillType(tradingBox.getType());
|
|
|
+ archivesTrajectory.setCode(tradingBoxItem.getCode());
|
|
|
+ archivesTrajectory.setAddress(tradingBoxItem.getAddress());
|
|
|
+ archivesTrajectory.setNewDate(tradingBoxItem.getNewDate());
|
|
|
+ archivesTrajectory.setCreateTime(new Date());
|
|
|
+ archivesTrajectory.setCreateUser(AuthUtil.getUserId());
|
|
|
+ archivesTrajectory.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ archivesTrajectory.setTenantId(AuthUtil.getTenantId());
|
|
|
+ archivesTrajectoryMapper.insert(archivesTrajectory);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("箱号不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tradingBox.setTradingBoxItemsList(tradingBoxItemList);
|
|
|
+ }
|
|
|
+ //费用明细
|
|
|
+ List<TradingBoxFees> tradingBoxFeesList = tradingBox.getTradingBoxFeesList();
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxFeesList) && tradingBoxFeesList.size() > 0) {
|
|
|
+ for (TradingBoxFees tradingBoxFees : tradingBoxFeesList) {
|
|
|
+ if (tradingBoxFees.getId() == null) {
|
|
|
+ tradingBoxFees.setCreateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxFees.setCreateTime(new Date());
|
|
|
+ tradingBoxFees.setTenantId(AuthUtil.getTenantId());
|
|
|
+
|
|
|
+ tradingBoxFeesMapper.insert(tradingBoxFees);
|
|
|
+ } else {
|
|
|
+ tradingBoxFees.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxFees.setUpdateTime(new Date());
|
|
|
+ tradingBoxFees.setPid(tradingBox.getId());
|
|
|
+ tradingBoxFeesMapper.updateById(tradingBoxFees);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tradingBox.setTradingBoxFeesList(tradingBoxFeesList);
|
|
|
+ }
|
|
|
+ //主表附件
|
|
|
+ List<TradingBoxFiles> tradingBoxFilesList = tradingBox.getTradingBoxFilesList();
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxFilesList) && tradingBoxFilesList.size() > 0) {
|
|
|
+ for (TradingBoxFiles tradingBoxFiles : tradingBoxFilesList) {
|
|
|
+ if (tradingBoxFiles.getId() == null) {
|
|
|
+ tradingBoxFiles.setCreateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxFiles.setCreateTime(new Date());
|
|
|
+ tradingBoxFiles.setTenantId(AuthUtil.getTenantId());
|
|
|
+ tradingBoxFiles.setPid(tradingBox.getId());
|
|
|
+ tradingBoxFiles.setType("1");
|
|
|
+ tradingBoxFilesMapper.insert(tradingBoxFiles);
|
|
|
+ } else {
|
|
|
+ tradingBoxFiles.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxFiles.setUpdateTime(new Date());
|
|
|
+ tradingBoxFiles.setPid(tradingBox.getId());
|
|
|
+ tradingBoxFiles.setType("1");
|
|
|
+ tradingBoxFilesMapper.updateById(tradingBoxFiles);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tradingBox.setTradingBoxFilesList(tradingBoxFilesList);
|
|
|
+ }
|
|
|
+ return tradingBox;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
public TradingBox checkTradingBox(TradingBox tradingBox) {
|