| | |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.BaseModel; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.CodeGenerateUtils; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.system.dto.InventoryDto; |
| | |
| | | supplierClinicId =crmClinic.getId(); |
| | | } |
| | | TErpSupplierInventory tErpSupplierInventory = new TErpSupplierInventory(); |
| | | String s = DateUtils.dateTimeNow(); |
| | | tErpSupplierInventory.setInventoryNumber("P" + s); |
| | | TErpSupplierInventory last1 = erpSupplierInventoryMapper.selectOne(new LambdaQueryWrapper<TErpSupplierInventory>().orderByDesc(BaseModel::getCreateTime).last("limit 1")); |
| | | if(last1==null){ |
| | | tErpSupplierInventory.setInventoryNumber("P" + DateUtils.dateTimeNow()+"00001"); |
| | | }else { |
| | | String lastProcurementCode = last1.getInventoryNumber(); |
| | | String datePart = "P" + DateUtils.dateTimeNow(); |
| | | |
| | | // 直接获取后五位数字并+1,不考虑是否同一天 |
| | | try { |
| | | String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5)); |
| | | int number = Integer.parseInt(numberPart); |
| | | if (number < 99999) { |
| | | number++; |
| | | } else { |
| | | number = 2; // 达到99999后重置为00002 |
| | | } |
| | | tErpSupplierInventory.setInventoryNumber(datePart + String.format("%05d", number)); |
| | | } catch (NumberFormatException e) { |
| | | // 如果解析失败,默认从00001开始 |
| | | tErpSupplierInventory.setInventoryNumber(datePart + "00001"); |
| | | } |
| | | } |
| | | |
| | | |
| | | tErpSupplierInventory.setWarehouseId(dto.getWarehouseId()); |
| | | tErpSupplierInventory.setSupplierId(supplierClinicId); |
| | | try { |
| | | erpSupplierInventoryMapper.insert(tErpSupplierInventory); |
| | | }catch (Exception e){ |
| | | throw new RuntimeException("网络繁忙,请重试"); |
| | | |
| | | } |
| | | |
| | | List<InventoryGoodsDto> dtos = dto.getDtos(); |
| | | for (InventoryGoodsDto inventoryGoodsDto : dtos) { |
| | |
| | | tErpSupplierWarehousing.setUnitAmount(tErpSupplierWarehousing1.getUnitAmount()); |
| | | tErpSupplierWarehousing.setTotalPrice(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(tErpSupplierWarehousing.getGoodsCount()))); |
| | | // 当前年月日时分秒 |
| | | String time = DateUtils.dateTimeNow(); |
| | | tErpSupplierWarehousing.setWarehouseNo("G" + time); |
| | | TErpSupplierWarehousing last = erpSupplierWarehousingMapper.selectOne(new LambdaQueryWrapper<TErpSupplierWarehousing>().orderByDesc(BaseModel::getCreateTime).last("LIMIT 1")); |
| | | if(last==null){ |
| | | tErpSupplierWarehousing.setWarehouseNo("G"+DateUtils.dateTimeNow()+"00001"); |
| | | }else { |
| | | String lastProcurementCode = last.getWarehouseNo(); |
| | | String datePart = "G" + DateUtils.dateTimeNow(); |
| | | |
| | | // 直接获取后五位数字并+1,不考虑是否同一天 |
| | | try { |
| | | String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5)); |
| | | int number = Integer.parseInt(numberPart); |
| | | if (number < 99999) { |
| | | number++; |
| | | } else { |
| | | number = 2; // 达到99999后重置为00002 |
| | | } |
| | | tErpSupplierWarehousing.setWarehouseNo(datePart + String.format("%05d", number)); |
| | | } catch (NumberFormatException e) { |
| | | // 如果解析失败,默认从00001开始 |
| | | tErpSupplierWarehousing.setWarehouseNo(datePart + "00001"); |
| | | } |
| | | } |
| | | tErpSupplierWarehousing.setType(2); |
| | | try { |
| | | erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing); |
| | | }catch (Exception e){ |
| | | throw new RuntimeException("网络繁忙,请重试"); |
| | | } |
| | | |
| | | // 添加批次信息 |
| | | TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch1 = new TErpSupplierWarehousingBatch(); |
| | |
| | | tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId()); |
| | | tErpSupplierOutbound.setSupplierId(supplierClinicId); |
| | | tErpSupplierOutbound.setOutboundType(1); |
| | | tErpSupplierOutbound.setOutboundNumber("G" + s); |
| | | TErpSupplierOutbound last = erpSupplierOutboundMapper.selectOne(new LambdaQueryWrapper<TErpSupplierOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1")); |
| | | if(last==null){ |
| | | tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+ "00001"); |
| | | }else { |
| | | String lastProcurementCode = last.getOutboundNumber(); |
| | | String datePart = "G" + DateUtils.dateTimeNow(); |
| | | |
| | | // 直接获取后五位数字并+1,不考虑是否同一天 |
| | | try { |
| | | String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5)); |
| | | int number = Integer.parseInt(numberPart); |
| | | if (number < 99999) { |
| | | number++; |
| | | } else { |
| | | number = 2; // 达到99999后重置为00002 |
| | | } |
| | | tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number)); |
| | | } catch (NumberFormatException e) { |
| | | // 如果解析失败,默认从00001开始 |
| | | tErpSupplierOutbound.setOutboundNumber(datePart + "00001"); |
| | | } |
| | | } |
| | | int count = inventoryGoodsDto.getDamagedCount(); |
| | | tErpSupplierOutbound.setTotalMoney(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(count))); |
| | | tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing2.getGoodsId()); |
| | | try { |
| | | erpSupplierOutboundMapper.insert(tErpSupplierOutbound); |
| | | }catch (Exception e){ |
| | | throw new RuntimeException("网络繁忙,请重试"); |
| | | |
| | | } |
| | | |
| | | TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods(); |
| | | tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId()); |
| | |
| | | tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId()); |
| | | tErpSupplierOutbound.setSupplierId(supplierClinicId); |
| | | tErpSupplierOutbound.setOutboundType(6); |
| | | tErpSupplierOutbound.setOutboundNumber("G" + s); |
| | | TErpSupplierOutbound last = erpSupplierOutboundMapper.selectOne(new LambdaQueryWrapper<TErpSupplierOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1")); |
| | | if(last==null){ |
| | | tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+ "00001"); |
| | | }else { |
| | | String lastProcurementCode = last.getOutboundNumber(); |
| | | String datePart = "G" + DateUtils.dateTimeNow(); |
| | | |
| | | // 直接获取后五位数字并+1,不考虑是否同一天 |
| | | try { |
| | | String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5)); |
| | | int number = Integer.parseInt(numberPart); |
| | | if (number < 99999) { |
| | | number++; |
| | | } else { |
| | | number = 2; // 达到99999后重置为00002 |
| | | } |
| | | tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number)); |
| | | } catch (NumberFormatException e) { |
| | | // 如果解析失败,默认从00001开始 |
| | | tErpSupplierOutbound.setOutboundNumber(datePart + "00001"); |
| | | } |
| | | } |
| | | int count = inventoryGoodsDto.getNum() - inventoryGoodsDto.getInventoryCount(); |
| | | tErpSupplierOutbound.setTotalMoney(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(count))); |
| | | tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing2.getGoodsId()); |
| | | try { |
| | | erpSupplierOutboundMapper.insert(tErpSupplierOutbound); |
| | | }catch (Exception e){ |
| | | throw new RuntimeException("网络繁忙,请重试"); |
| | | } |
| | | |
| | | |
| | | |
| | | TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods(); |
| | |
| | | |
| | | } |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) |
| | | public void inventoryGoods1(InventoryDto dto, SysUser user) { |
| | | Integer roleType = user.getRoleType(); |
| | | String supplierClinicId = null; |
| | |
| | | supplierClinicId =crmClinic.getId(); |
| | | } |
| | | TErpClinicInventory tErpSupplierInventory = new TErpClinicInventory(); |
| | | String s = DateUtils.dateTimeNow(); |
| | | tErpSupplierInventory.setInventoryNumber("P" + s); |
| | | TErpClinicInventory last = erpClinicInventoryMapper.selectOne(new LambdaQueryWrapper<TErpClinicInventory>().orderByDesc(BaseModel::getCreateTime).last("limit 1")); |
| | | if(last==null){ |
| | | tErpSupplierInventory.setInventoryNumber("P" + DateUtils.dateTimeNow()+"00001"); |
| | | }else { |
| | | String lastProcurementCode = last.getInventoryNumber(); |
| | | String datePart = "P" + DateUtils.dateTimeNow(); |
| | | // 直接获取后五位数字并+1,不考虑是否同一天 |
| | | try { |
| | | String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5)); |
| | | int number = Integer.parseInt(numberPart); |
| | | if (number < 99999) { |
| | | number++; |
| | | } else { |
| | | number = 2; // 达到99999后重置为00002 |
| | | } |
| | | tErpSupplierInventory.setInventoryNumber(datePart + String.format("%05d", number)); |
| | | } catch (NumberFormatException e) { |
| | | // 如果解析失败,默认从00001开始 |
| | | tErpSupplierInventory.setInventoryNumber(datePart + "00001"); |
| | | } |
| | | } |
| | | |
| | | tErpSupplierInventory.setClinicId(supplierClinicId); |
| | | try { |
| | | erpClinicInventoryMapper.insert(tErpSupplierInventory); |
| | | |
| | | }catch (Exception e){ |
| | | throw new RuntimeException("网络繁忙,请重试"); |
| | | } |
| | | |
| | | |
| | | List<InventoryGoodsDto> dtos = dto.getDtos(); |
| | | for (InventoryGoodsDto inventoryGoodsDto : dtos) { |
| | |
| | | String warehousingId = tErpSupplierWarehousingBatch.getWarehousingId(); |
| | | TErpClinicWarehousing tErpSupplierWarehousing1 = erpClinicWarehousingMapper.selectById(warehousingId); |
| | | TErpGoods erpGoods = this.getById(tErpSupplierWarehousingBatch.getGoodsId()); |
| | | |
| | | |
| | | |
| | | // 盘点是盘亏盘盈 赢 |
| | | if (inventoryGoodsDto.getNum() < inventoryGoodsDto.getInventoryCount()) { |
| | |
| | | // tErpSupplierWarehousing.setUnitAmount(erpGoods.getSalesAmount()); |
| | | tErpSupplierWarehousing.setTotalPrice(tErpSupplierWarehousingBatch.getUnitAmount().multiply(new BigDecimal(inventoryGoodsDto.getInventoryCount() - inventoryGoodsDto.getNum()))); |
| | | // 当前年月日时分秒 |
| | | String time = DateUtils.dateTimeNow(); |
| | | tErpSupplierWarehousing.setWarehouseNo("G" + time); |
| | | TErpClinicWarehousing last1 = erpClinicWarehousingMapper.selectOne(new LambdaQueryWrapper<TErpClinicWarehousing>().orderByDesc(BaseModel::getCreateTime).last("limit 1")); |
| | | if(last1==null){ |
| | | tErpSupplierWarehousing.setWarehouseNo("G" + DateUtils.dateTimeNow()+"00001"); |
| | | }else { |
| | | String lastProcurementCode = last1.getWarehouseNo(); |
| | | String datePart = "G" + DateUtils.dateTimeNow(); |
| | | // 直接获取后五位数字并+1,不考虑是否同一天 |
| | | try { |
| | | String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5)); |
| | | int number = Integer.parseInt(numberPart); |
| | | if (number < 99999) { |
| | | number++; |
| | | } else { |
| | | number = 2; // 达到99999后重置为00002 |
| | | } |
| | | tErpSupplierWarehousing.setWarehouseNo(datePart + String.format("%05d", number)); |
| | | } catch (NumberFormatException e) { |
| | | // 如果解析失败,默认从00001开始 |
| | | tErpSupplierWarehousing.setWarehouseNo(datePart + "00001"); |
| | | } |
| | | |
| | | } |
| | | tErpSupplierWarehousing.setType(2); |
| | | tErpSupplierWarehousing.setInventoryId(tErpSupplierInventory.getId()); |
| | | if(erpGoods.getGoodsSource()==1){ |
| | |
| | | }else { |
| | | tErpSupplierWarehousing.setSupplierName(erpGoods.getSupplierName()); |
| | | } |
| | | try { |
| | | erpClinicWarehousingMapper.insert(tErpSupplierWarehousing); |
| | | }catch (Exception e){ |
| | | throw new RuntimeException("网络繁忙,请重试"); |
| | | } |
| | | |
| | | // 添加批次信息 |
| | | TErpClinicWarehousingBatch tErpSupplierWarehousingBatch1 = new TErpClinicWarehousingBatch(); |
| | |
| | | |
| | | } else { |
| | | |
| | | |
| | | if(inventoryGoodsDto.getDamagedCount()!=null && inventoryGoodsDto.getDamagedCount()>0){ |
| | | TErpClinicOutbound tErpSupplierOutbound = new TErpClinicOutbound(); |
| | | // tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId()); |
| | | // tErpSupplierOutbound.setSupplierId(supplierClinicId); |
| | | tErpSupplierOutbound.setOutboundType(1); |
| | | tErpSupplierOutbound.setOutboundNumber("G" + s); |
| | | TErpClinicOutbound last2 = erpClinicOutboundMapper.selectOne(new LambdaQueryWrapper<TErpClinicOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1")); |
| | | if(last2==null){ |
| | | |
| | | tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+"00001"); |
| | | }else { |
| | | String lastProcurementCode = last2.getOutboundNumber(); |
| | | String datePart = "G" + DateUtils.dateTimeNow(); |
| | | // 直接获取后五位数字并+1,不考虑是否同一天 |
| | | try { |
| | | String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5)); |
| | | int number = Integer.parseInt(numberPart); |
| | | if (number < 99999) { |
| | | number++; |
| | | } else { |
| | | number = 2; // 达到99999后重置为00002 |
| | | } |
| | | tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number)); |
| | | } catch (NumberFormatException e) { |
| | | // 如果解析失败,默认从00001开始 |
| | | tErpSupplierOutbound.setOutboundNumber(datePart + "00001"); |
| | | } |
| | | } |
| | | int count = inventoryGoodsDto.getDamagedCount(); |
| | | tErpSupplierOutbound.setTotalMoney(erpGoods.getSalesAmount().multiply(new BigDecimal(count))); |
| | | tErpSupplierOutbound.setInventoryId(tErpSupplierInventory.getId()); |
| | | try { |
| | | erpClinicOutboundMapper.insert(tErpSupplierOutbound); |
| | | }catch (Exception e){ |
| | | throw new RuntimeException("网络繁忙,请重试"); |
| | | } |
| | | |
| | | |
| | | TErpClinicOutboundGoods tErpSupplierOutboundGoods = new TErpClinicOutboundGoods(); |
| | |
| | | // tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId()); |
| | | // tErpSupplierOutbound.setSupplierId(supplierClinicId); |
| | | tErpSupplierOutbound.setOutboundType(6); |
| | | tErpSupplierOutbound.setOutboundNumber("G" + s); |
| | | TErpClinicOutbound last4 = erpClinicOutboundMapper.selectOne(new LambdaQueryWrapper<TErpClinicOutbound>().orderByDesc(BaseModel::getCreateTime).last("limit 1")); |
| | | if(last4==null){ |
| | | tErpSupplierOutbound.setOutboundNumber("G" + DateUtils.dateTimeNow()+"00001"); |
| | | }else { |
| | | String lastProcurementCode = last4.getOutboundNumber(); |
| | | String datePart = "G" + DateUtils.dateTimeNow(); |
| | | // 直接获取后五位数字并+1,不考虑是否同一天 |
| | | try { |
| | | String numberPart = lastProcurementCode.substring(Math.max(0, lastProcurementCode.length() - 5)); |
| | | int number = Integer.parseInt(numberPart); |
| | | if (number < 99999) { |
| | | number++; |
| | | } else { |
| | | number = 2; // 达到99999后重置为00002 |
| | | } |
| | | tErpSupplierOutbound.setOutboundNumber(datePart + String.format("%05d", number)); |
| | | } catch (NumberFormatException e) { |
| | | // 如果解析失败,默认从00001开始 |
| | | tErpSupplierOutbound.setOutboundNumber(datePart + "00001"); |
| | | } |
| | | |
| | | } |
| | | int count = inventoryGoodsDto.getNum() - inventoryGoodsDto.getInventoryCount(); |
| | | tErpSupplierOutbound.setTotalMoney(tErpSupplierWarehousingBatch.getSalesAmount().multiply(new BigDecimal(count))); |
| | | tErpSupplierOutbound.setInventoryId(tErpSupplierInventory.getId()); |
| | | try { |
| | | erpClinicOutboundMapper.insert(tErpSupplierOutbound); |
| | | }catch (Exception e){ |
| | | throw new RuntimeException("网络繁忙,请重试"); |
| | | } |
| | | |
| | | |
| | | TErpClinicOutboundGoods tErpSupplierOutboundGoods = new TErpClinicOutboundGoods(); |